易截截图软件、单文件、免安装、纯绿色、仅160KB

Python: python写的一个简单网络词典

闲来无事, 玩玩python...
是采用有道翻译, 然后抓取网页的.
import re, urllib
url="http://dict.youdao.com/search?le=eng&q="
print ("input q to exit")
while 1:
word = raw_input(">>>")
if word=="q":
exit()
else:
word = word.replace(' ', '+')
url += word
url += "&tab=chn&keyfrom=dict.top"
s = urllib.urlopen(url).read()

comm1 = re.compile(';</td><td class="attributem1web">.*?</td>')
result=comm1.findall(s)
comm2 = re.compile(r'<td class="dttitle2"><font color="#013694"><b>.*?<\/b><\/font><\/td>')
related = comm2.findall(s)

#find the result
if result:
print 'meaning:'
for i in result:
temp = i.decode('utf8').encode('cp936')
temp = temp[33:]
temp = temp[:-5]
print temp
print '\n'
#fine the matters
if related:
print 'related:'
for i in related:
temp = i.decode('utf8').encode('cp936')
temp = temp[46:]
temp = temp[:-16]
print temp
print '\n'

else:
print 'no such word!'


相关文档:

解压文件夹中的压缩文件 Python脚本

下载了很多压缩文件,就写了一个脚本
在Python中使用winrar命令,所以一般压缩文件都支持
有些压缩文件Python中还没有相应的库
你得先把winrar添加到path环境变量中
把代码保存为rar.py
在dos下使用,如:rar.py "D:\A B\C" mkdir
#rar.py
#decompress with winrar
#arguments :filename directory opt
# op ......

Python发展史

Python的创始人为Guido van
Rossum。1989年圣诞节期间,在阿姆斯特丹,Guido为了打发圣诞节的无趣,决心开发一个新的脚本解释程序,做为 ABC
语言的一种继承。之所以选中 Python(大蟒蛇的意思)作为程序的名字,是因为他是一个Monty Python的飞行马戏团的爱好者。
ABC是由Guido参加设计的一种教学语言。就Guido本人看 ......

保存指定文件夹下的目录和文件名到文件中 Python 脚本

真是倒霉,刚买不久的移动硬盘,昨天删除一个分区失败后,几个分区都不见了,拿去修,未果
换了个新的,但其中数据全没了。那是我平时收集的很有用的资料
很多都可以重新下载,但怎能想起硬盘中的所有东西
今天换硬盘回来
就像写一个保存指定路径下所有文件夹和文件名的程序
这样,如果东西丢了,看看那里有些什么,也 ......

Python 中列出目录中所有文件的方法


Python代码
import string, os, sys   
  
dir = '/var'  
print '----------- no sub dir'  
  
files = os.listdir(dir)   
for f in files:   
   ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号