һƪ²»´íµÄPythonÈëÃŽ̳Ì
ÔÎÄ
http://www.hetland.org/python/instant-hacking.php
Instant Hacking[Òë
ÎÄ]
ÒëÕߣº ¿Ï¶¨À´¹ý
ÕâÊÇһƪ¼ò¶Ì
µÄ¹ØÓÚpython³ÌÐòÉè¼ÆÓïÑÔµÄÈëÃŽ̳̣¬ÔÎÄÔÚÕâÀ·×Ŵʵä·ÒëÁËÀ´£¡
ÕâÊÇÒ»·Ý¶Ô±à³ÌÒÕÊõµÄ¼ò¶Ì½éÉÜ£¬ÆäÖеÄÀý×ÓÊÇÓÃ
pythonд³ÉµÄ¡£(Èç¹ûÄãÒѾ֪µÀÁ˸ÃÈçºÎ±à³Ì£¬µ«ÊÇÏë¼òµ¥Á˽âÒ»ÏÂpython£¬Äã¿ÉÒÔ²éÔÄÎÒµÄÁíһƪÎÄÕÂInstant Python¡££©ÕâƪÎÄ
ÕÂÒѾ±»·ÒëΪÒâ´óÀû¡¢²¨À¼¡¢ÈÕ±¾¡¢Èû¶ûάÑÇÒÔ¼°°ÍÎ÷ÆÏÌÑÑÇÓïµÈÐí¶àÖÖÓïÑÔ£¬¶øÇÒÕýÔÚ±»·ÒëΪº«Óï¡££¨ÒëÕߣºµ±È»£¬ÏÖÔÚÒѾ°üÀ¨ÁËÖÐÎÄ°æ±¾£¬Ö»ÊÇ×÷Õß²¢²»
ÖªµÀ¡££©
ÕâƪÎÄÕºÍÈçºÎ´³Èë±ðÈ˵ļÆËã»úϵͳ֮ÀàµÄ¶«Î÷Î޹ء£ÎÒ²»¹Ø×¢ÄÇÀàÊÂÇ飬ËùÒÔÇë²»ÒªemailÎÊÎÒÄÇЩ¶«Î÷¡£
×¢
Ò⣺Ҫʹ´ËÎÄÖеÄÀý×ÓÕýÈ·ÔËÐУ¬ÄãÓ¦¸Ã°ÑËüÃÇдÔÚÒ»¸öÎı¾ÎļþÖУ¬È»ºóÓýâÊÍÆ÷ÔËÐУ»²»ÒªÊÔͼֱ½ÓÔÚ½»»¥·½Ê½ÏÂÔËÐÐËüÃÇ££²»ÊÇËùÓеĶ¼¿ÉÒÔÕâÑùÔË
ÐС££¨²»ÒªÎÊÎҺʹËÓйصľßÌåϸ½Ú¡£×îºÃ²éÔÄpythonÎĵµ»òÕßemail¸øhelp@python.org£©¡£
1. ÔË
Ðл·¾³
ÒªÓÃpythonд³ÌÐò£¬Äã±ØÐëÏÈ°²×°Ò»¸öpythonµÄ½âÊÍÆ÷¡£Ëü¿ÉÒÔ´æÔÚÓÚ´ó¶àÊýƽ̨£¨°üÀ¨
Macintosh¡¢UnixºÍWindows£©¡£¸ü¶àÓë´ËÓйصÄÐÅÏ¢¿ÉÒÔÔÚpythonµÄÍøÕ¾ÉÏÕÒµ½¡£Ä㻹Ӧ¸ÃÓÐÒ»¸öÎı¾±à¼Æ÷£¨Ïóemacs¡¢
notepad»òÕßÀàËƵĶ«Î÷£©¡£
2. ±à³ÌÊÇʲô£¿
Ϊ¼ÆËã»úд³ÌÐòÆäʵ¾ÍÊǸø
ËüһϵÁеÄÖ¸Áî¸æËßËüÈ¥×öʲô¡£¼ÆËã»ú³ÌÐòÔÚijЩ·½Ãæ¾ÍÏóÊDzËÆ×£¬Ö¸µ¼ÎÒÃÇÈçºÎ×ö²ËµÄÄÇÖÖ¡£ÀýÈç£Û1£Ý£º
¼ÙÈÕ»ðÍÈɳÀ
Ô
ÁÏ£º
ëçÅÝÖ£º
1/4±Ëá³ÈÖ
1/4±µÍÄƴ󶹽´ÓÍ
1/4±Ë®
1´óÌÀ³×Ö²ÎïÓÍ
3/4
²è³×СÜîÏã
1/2²è³×Å£ÖÁ
1/4²è³×ÈȺú½··Û
2Ƭ¶¡Ïã¡¢´óË⣬µ·Ëé
ɳÀ£º
1·Ý£¨12°»Ë¾£©¹Þ
×°ÉÙÄÆÎç²ÍÈâ»ðÍÈÇгÉÌõ×´
1¸öÑó´Ð£¬ÇÐƬ
ºú½··Û£¬ÇкõÄÉú²Ë
12¸öÓ£ÌÒÎ÷ºìÊÁ£¬Çаë
·½·¨£º
°Ñ
ëçÅÝÖ×°ÔÚÓкÏÊʸÇ×ӵĹã¿ÚÆ¿ÀïÒ¡ÔÈ¡£ÓÃËÜÁÏ´ü×°ÉÏ»ðÍÈ£¬ÆÃÉÏëçÅÝÖ£¬·âס´ü¿Ú¡£ÔÚµç±ùÏäÀïëçÖÆ30·ÖÖÓ¡£´ÓËÜÁÏ´üÀïÈ¡³ö»ðÍÈ£»×¼±¸2´óÌÀ³×ëçÅÝÖ£¬ÔÚÖó
¹øÀïÖóһϡ£¼ÓÉÏ»ðÍÈ¡¢Ñó´Ð¡¢ÂÌÉ«µÄºú½·¡£ÉÕ3µ½4·ÖÖÓÖ±µ½»ðÍÈÊìÁËΪֹ……
µ
Ïà¹ØÎĵµ£º
PythonÖ§³Öascii×Ö·û´®£¬unicode×Ö·û´®£¬ÒÔ¼°¸÷ÖÖ×Ö·û¼¯£¬ÄÇôËüÃǵ½µ×¸÷ÊÇʲô¸ÅÄÏ໥֮¼ä´æÔÚºÎÖÖ¹ØϵÄØ£¿
ÔÚPythonÖУ¬ascii×Ö·û´®£¬¼´strÀàÐ͵ÄÖµ£¬¿ÉÄÜÓÃÀ´±íʾÈÎÒâµÄÒ»¿é´æ´¢¿Õ¼ä£¬ÄÇôҲ¾ÍÊÇ˵£¬Õâ¸ö×Ö·û´®ÄÚ²¿¿ÉÒÔÊÇÈκÎÖµ£¬ÀýÈ磺¿É¼û×Ö·û×é³ÉµÄ×Ö·û´®£¬»òÕßÒ»¶Î¶þ½øÖÆÊý¾ÝµÈ¡£unicode×Ö·û´®£¬¼´unicodeÀàÐ굀 ......
Ubuntuƽ̨ϵÄPython²Ù×÷Mysql
1.°²×°Ubuntu,°²×°Msql.
2.´ò¿ªÖÕ¶Ë,ÊäÈë python
import MySQLdb
con = MySQLdb.connect(db="python")
cur = con.cursor()
count = cur.execute("select * from test")
print count
data = cur.fetchall()
print data
for d in data:
print d
import os
os.system('clear') ......
ÒÔǰûÓÐд¹ýpython½Å±¾£¬ÓÚÊÇÕÒÁËÒ»¸ö¼òÒ׵Ľ̳̹ýÁËÒ»±éÓÚÊǾÍÊǸÉÁË¡£
ÕâÁ½Ìì²âÊÔmysql archiveÒýÇæµÄÐÔÄÜ£¬ÓÚÊÇÓÃpythonÏòarchive±íÖвåÈë10ÒÚÌõÊý¾Ý£¬python´óÖÂÊÇÈçÏÂдµÄ£º
for i in range(0,100000000)
insert into ....
½á¹ûÖ´ÐÐÖ®ºóϵͳ¾ÍËÀ»úÁË£¬ÇóÖú“ΰ¸ç”£¬×îºó·¢ÏÖÔÙÖ´Ðнű¾µÄʱºò£¬for in ......
ΪÁËÑ¡ÔñÒ»¸öºÏÊʵĽű¾ÓïÑÔѧϰ£¬½ñÌì²éÁ˲»ÉÙÓйØPerl£¬Python£¬Ruby£¬JavascriptµÄ¶«Î÷£¬¿ÉÊÇ·¢ÏÖ¸÷´óÕóÓªµÄÈ˶¼ÔÚ´µÅõ×Ô¼ºÏ²»¶µÄÓïÑÔ£¬²»¹ý×îûÓÐÕùÒéµÄÓ¦¸ÃÊÇJavascriptÏֽ׶λ¹²»ÊʺÏÓÃÀ´×ö¶ÀÁ¢¿ª·¢£¬ËüµÄÌìÏ»¹ÊÇÔÚwebÓ¦ÓÃÉÏ¡£ ÎÒÖ÷ÒªÊÇÏë×öÊý¾ÝÍÚ¾òËã·¨µÄÑо¿£¬Ó¦¸Ã»á´¦Àí´óÁ¿µÄÎı¾¡£Ìáµ½Îı¾´¦Àí£¬ÏàÐŴ󲿷ÖÈË ......
c´úÂë:
int x = a>b?6,6;
ÕâÖÖÓï¾äPythonÖÐÒ²ÓУº
¿ÉÒÔͨ¹ýand or×éºÏÀ´ÊµÏÖ¡£¸öÈËÈÏΪÕâÖÖÓï¾ä¾¡Á¿ÉÙµãºÃ¡£
python°ÑÕâÀàÐ͵ŦÄÜ·¢Ñï¹âÁË´ó¡£µ«ÊÇÓÉÓÚÕâÖÖ×éºÏ±È½ÏÈÆ£¬ËùÒÔÓÐʱºò±È½Ï¾À½á:
±ÈÈç:
5 or 6 and 6 ·µ»Øwhat?
0 or 5 ·µ»Øwhat?
8 and 7 ·µ»Øwhat?
ÓÚÊÇÕûÀíÁËÏ£º
1.pyhon ÖÐÓ ......