Python²éÕÒÌæ»»
>>> import string
>>> s='adbecf'
>>>
tt=string.maketrans("abc","ABC")
>>> s.translate(tt,"")
'AdBeCf'
>>>
s.translate(tt,"")
ºóÃæµÄÄǸö¿Õ×Ö·û´´¾ÍÊÇÄãҪɾ³ýµÄ×Ö·û£¬±ÈÈçҪɾ³ý»»ÐоÍÊÇs.translate(tt,"\n")
Ïà¹ØÎĵµ£º
½ñÌìѧϰÁËÒ»ÏÂPythonµÄ²Ù×÷·ûÖØÔØ£¬×ܽáÁ˼¸µã±È½ÏÉñÆæµÄ¶«¶«£º
------------------------------------------------------------------------------------------------------------
¹ØÓÚiter£º
Technically, iteration contexts work by calling the iter built-in function to try to
find an _ _iter_ _ method, whi ......
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') ......
Éè¼ÆÄ£Ê½ÊÇÒ»¸ö³éÏó²ã´Î£¬ÃèÊöÁËÔÚÒ»¸öÌØ¶¨µÄ»·¾³ÖÐÓÃÀ´½â¾öÒ»°ãÉè¼ÆÎÊÌâµÄ¶ÔÏóºÍÀàÖ®¼äµÄ½»»¥¹ØÏµ£¬ÆäÖ÷ҪĿµÄÊdzä·ÖÀûÓÃÓïÑÔµÄÌØÐÔ£¬Éè¼Æ¿É¸´Óõġ¢Äܹ»ÊÊÓ¦ÐèÇó±ä¸üµÄÈí¼þ[9]¡£Éè¼ÆÄ£Ê½ÊÇÒ»ÖÖÉè¼ÆË¼Ï룬ÓïÑÔÊÇʵÏÖ˼ÏëµÄ¹¤¾ß¡£Òò´Ë£¬²»Í¬ÓïÑÔµÄÌØÐÔÓ°ÏìÁËÉè¼ÆÄ£Ê½µÄʵÏÖ£¬ÓÐЩÓïÑÔ¸üÈÝÒ×ʵÏÖÉè¼ÆÄ£Ê½£¬¶øÓÐЩÓïÑÔÔ ......
# -*- coding: utf-8 -*-
import urllib2
from BeautifulSoup import BeautifulSoup, Tag
import re
page = urllib2.urlopen("http://bj.ganji.com/piao/zz_%E5%8C%97%E4%BA%AC-%E5%8D%97%E6%98%8C/20100210/")
soup = BeautifulSoup(page)
#ss = soup.findAll('a', href=re.compile(r"^/piao/100.&qu ......