PythonѧϰÔý¼Ç
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') # clear screen
count = cur.execute("delete from test where id =1")
print count
count = cur.execute("select * from test")
print count
cur.close()
con.commit()
con.close()
ps.pythonѧϰÊé¼®
1.python¼òÃ÷½Ì³Ì
http://www.woodpecker.org.cn:9081/doc/abyteofpython_cn/chinese/
2.pythonºËÐıà³Ì(µÚ¶þ°æ)
Ïà¹ØÎĵµ£º
1¡¢ÔÚPythonÖÐ×î»ù±¾µÄÊý¾Ý½á¹¹ÊÇÐòÁУ¨sequence£©£¬ÐòÁÐÖеÄÿ¸öÔªËØ±»·ÖÅäÒ»¸öÊý×Ö——ÔªËØµÄλÖã¬Ò²½ÐË÷Òý¡£µÚÒ»¸öË÷ÒýÊÇ 0£¬µÚ¶þ¸öË÷ÒýÊÇ1£¬Èç´ËµÝÍÆ¡£ÐòÁÐÖеÄ×îºóÒ»¸öÌõÄ¿±»±ê¼ÇΪ-1£¬µ¹ÊýµÚ¶þÊÇ-2£¬Èç´ËµÝÍÆ¡£
2¡¢ÐòÁУºeg:edward = ['Edward Gumby', 42]£¬ÐòÁÐÒ²Äܰüº¬ÆäËûµÄÐòÁС£Ð ......
´Õ24ÊǾµäµÄÒæÖÇÓÎÏ·£¬¶àÍæ¿ÉÒÔʹÄÔ½îÁé»îÒ»µã£¬µ«Êǵ±Óöµ½ÎÞ½âµÄʱºò£¬¾Í»áºÜÉËÄԽΪ´Ë£¬Ð´¸ö³ÌÐòÀ´´úΪ¼ÆËã¡£
ÔËÐнá¹û£¬È¥³ýÁËÖØ¸´µÄһЩ±í´ïʽ£º
entry: 1
entry: 4
entry: 5
entry: 6
(4/(1-(5/6))) = 24
(6/((5/4)-1)) = 24
Press any key to exit...
entry: 3
entry: 3
entry: 8
entry: 8
(8/(3-(8 ......
ÔÎijö´¦£ºhttp://www.amk.ca/python/howto/regex/
ÔÎÄ×÷ÕߣºA.M. Kuchling £¨amk@amk.ca£©
ÊÚȨÐí¿É£º´´×÷¹²ÏíÐÒé
·ÒëÈËÔ±£ºFireHare
У¶ÔÈËÔ±£ºLeal
ÊÊÓð汾£ºPython 1.5 ¼°ºóÐø°æ±¾
¼ò½é
Python ×Ô1.5°æ±¾ÆðÔö¼ÓÁËre Ä£¿é£¬ËüÌṩ Perl ·ç¸ñµÄÕýÔò±í´ïʽģʽ¡£Python 1.5֮ǰ°æ±¾ÔòÊÇͨ¹ý regex
Ä£¿éÌṩ ......
PythonÖ§³Öascii×Ö·û´®£¬unicode×Ö·û´®£¬ÒÔ¼°¸÷ÖÖ×Ö·û¼¯£¬ÄÇôËüÃǵ½µ×¸÷ÊÇʲô¸ÅÄÏ໥֮¼ä´æÔÚºÎÖÖ¹ØÏµÄØ£¿
ÔÚPythonÖУ¬ascii×Ö·û´®£¬¼´strÀàÐ͵ÄÖµ£¬¿ÉÄÜÓÃÀ´±íʾÈÎÒâµÄÒ»¿é´æ´¢¿Õ¼ä£¬ÄÇôҲ¾ÍÊÇ˵£¬Õâ¸ö×Ö·û´®ÄÚ²¿¿ÉÒÔÊÇÈκÎÖµ£¬ÀýÈ磺¿É¼û×Ö·û×é³ÉµÄ×Ö·û´®£¬»òÕßÒ»¶Î¶þ½øÖÆÊý¾ÝµÈ¡£unicode×Ö·û´®£¬¼´unicodeÀàÐ굀 ......
1.1. Óï·¨
1.1.1. if
>>> x=int(raw_input("please enter an integer:"))
please enter an integer:-8
>>> if x<0:
... print 'negative'
... elif x==0:
... print 'zero'
... else:
... print 'positive'
...
negative
ÕâÀïÓм¸¸ö֪ʶµãÐèÒªÌáÐÑ£º
1¡£ºÍ ......