写了几个有关operaminimod的python小程序
写了几个有关operaminimod的python小程序
firefox->opm书签转换
import re
def pipeiwangzhi(a):
s=[]
pp= re.compile(r'<DT><A HREF="(.*)" ADD_DATE=(.*>)(.*)</A>')
m=pp.search(a)
s1=[]
if m!=None:
s=m.groups()
s1.append(s[0])
s1.append(s[2])
return s1
fnlang='f:\\bookmarks.html'
f1 = open(fnlang,'rb')
ffbk=f1.readlines()
f1.close()
opbkmg=[]
for i in ffbk:
a=i.decode('utf-8')
ss=[]
ss=pipeiwangzhi(a)
if ss!=[]:
opbkmg.append(ss)
#print(opbkmg)
tou="""<!DOCTYPE NETSCAPE-Bookmark-file-1>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<!--This is generated file from Opera Mini mod v.3.12.
It will be read and overwritten.
Do Not Edit! -->
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><P>\n"""
x1='<DT><img src="" alt="" width="12" height="12" /><A HREF="'
x2='">'
x3='</A><PARAM NAME="fav" VALUE="0:/">\n'
wei='</DL><P>'
opbk=''
for i in opbkmg:
opbk+=x1+i[0]+x2+i[1]+x3
opbk=tou+opbk+wei
#print(opbk.encode('utf-8'))
fnlang='f:\\bookmarks.htm'
f1 = open(fnlang,'wb')
f1.write(opbk.encode('utf-8'))
f1.close()
相关文档:
Python代码
import string, os, sys
dir = '/var'
print '----------- no sub dir'
files = os.listdir(dir)
for f in files:
......
闲来无事, 玩玩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
u ......
前一段时间试着用这三种语言简单的写了关于文件拷贝的程序,发现c#和python的api惊人的相似,对于文件的操作这两种语言非常的方便。都没有加异常的处理
C#源代码:
public static void CopyFile(string source, string destination)
& ......
multiprocessing — Process-based “threading” interface
Introduction
multiprocessing is a package that supports spawning processes using an API similar to the threading module. The multiprocessing package offers both local and remote concurrency, effectively side-stepping the Glo ......