写了几个有关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()
相关文档:
Script Name: Spider_Create
#Script Label: Create Spider Diagrams
#
#Description: Custom python script developed to create spider diagrams from points contained
#in one or two feature classes. If using two fea ......
def Start(self):
if (self.conn == None) or (self.conn.State == 1):
self.conn = win32com.client.Dispatch(r'ADODB.Connection')
&n ......
#
-*- encoding: gb2312 -*-
import
os, sys, string
import
MySQLdb
#
连接数据库
try
:
conn
=
MySQLdb.connect(host
=
'
localhost
'
,user
=
'
root
'
,passwd
=
'
xxxx
'
,db
=
'
test1
'
)
except
Exception, e:
print
e
sys.exit()
......
8.8. queue — A synchronized queue class¶
queue -- 一个同步队列类
The queue module implements multi-producer, multi-consumer queues. It is especially useful in threaded programming when information must be exchanged safely between multiple threads. The Queue class in this module implemen ......
原帖:http://www.cnblogs.com/jingleguo/archive/2008/06/02/1211820.html
当python中间处理非ASCII编码时,经常会出现如下错误:
UnicodeDecodeError: 'ascii' codec can't decode byte 0x?? in position 1: ordinal not in range(128)
0x??是超出128的数字,python在默认的情况下认为语言的编码是ascii编码,所以无法 ......