дÁ˼¸¸öÓйØ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>
&l ......
ÕâÊÇÒ»¸ö¼òµ¥µÄ±í´ïʽ¼ÆËãÆ÷, ²»Ì«¶®ÓÃTkinterдGUI, ²Î¿¼Á˱ðÈ˵ĴúÂë
from __future__ import division
from Tkinter import Tk, Entry, Button, Label, mainloop
from tkFont import Font
def get_value ():
v = ''
try:
v = eval(text.get()) #use eval to calculate the vlaue of the text
except:
pass
if isinstance(v, (int, float, long)):
pass
else:
v = 'Error...'
label.config(text = v) #use config to change the text
top = Tk()
top.title("calculator")
ft = Font(family = 'Courier New', size = 12)
text = Entry(top, font = ft)
button = Button(top, text = 'Ok', command = get_value)
label = Label(text = '(+ - * / % **)', font = ft)
Enter = lambda x: x.keycode == 13 and get_value()
Key = lambda x: label.config(text = '(+ - * / % **)')
text.bind('<Key>', Enter) #when the key is enter, execute the function Enter
text.focus()
text.bind('<Button-1>', Key) #when click the left-key, execute the function Key
text.pack()
button.pack()
label.pack()
mainloo ......
ÕâÊÇÒ»¸öÎÒÃÇÔÚ´¦ÀíÖÐÎÄʱ, ¾³£Óöµ½µÄÎÊÌâ.
pythonÀïÃæ»ù±¾ÉÏÒª¿¼ÂÇÈýÖÖ±àÂë¸ñʽ
1 Ô´Îļþ±àÂë
ÔÚÎļþÍ·²¿Ê¹ÓÃcodingÉùÃ÷¡£¸æËßpython½âÊÍÆ÷¸Ã´úÂëÎļþËùʹÓõÄ×Ö·û¼¯¡£
#/usr/bin/python
#coding: utf8
2 ÄÚ²¿±àÂë
´úÂëÎļþÖеÄ×Ö·û´®£¬¾¹ýdecodeÒԺ󣬱»×ª»»ÎªÍ³Ò»µÄunicode¸ñʽµÄÄÚ²¿Êý¾Ý£¬ÀàËÆÓÚu'*'¡£unicodeÊý¾Ý¿ÉÒÔʹÓÃencodeº¯Êý£¬ÔÙ×ÔÓÉת»»ÎªÆäËû¸ñʽµÄÊý¾Ý£¬Ï൱ÓÚÒ»¸öͳһµÄƽ̨¡£
Ö±½ÓÊäÈëunicodeÊý¾Ý
>>> u'ÄãºÃ'
u'\u4f60\u597d'
½«unicodeÊý¾Ýת»»Îªgb2312¸ñʽ
>>> u'ÄãºÃ'.encode('gb2312')
'\xc4\xe3\xba\xc3'
½«ÊäÈëµÄgb2312¸ñʽµÄÊý¾Ý½âÂëΪunicode
>>> 'ÄãºÃ'.decode('gb2312')
u'\u4f60\u597d'
ÊäÈëÊý¾ÝµÄ¸ñʽȡ¾öÓÚËùÓÃshellÖն˵ıàÂëÉèÖ㬱¾ÀýÖÐΪzh_CN
[root@chenzheng python]# echo $LANG
zh_CN
½âÂëͬʱת»»Îªutf8
>>> 'ÄãºÃ'.decode('gb2312').encode('utf8')
'\xe4\xbd\xa0\xe5\xa5\xbd'
3 ÍⲿÊäÈëµÄ±àÂë
ÆäʵÕâ¸öºÍÔÚpython½»»¥shellÖÐÊäÈëµÄ×Ö·û´®£¬ËùÓöµ½µÄÇé¿ö»ù±¾Ò»Ñù¡£µ«³ÌÐòÖг£³£Óõ½´ÓÍøÂ磬Îļþ¶ÁÈ¡µÄÊý¾Ý£¬¹Ê´Ëµ¥¶ÀÁгö£¬ÐèÒªÌØ±ð×¢ÒâÆä±àÂë¸ñʽÊÇ·ñÓÚÏµÍ³ÒªÇ ......
1.³£Ó÷½·¨£¬²»´ø²ÎÊý
def decator(func):
def inner_func(*args):
args = (i * 2 for i in args)
return func(*args)
return inner_func
@decator
def add(a, b, c):
return a + b + c
2.´ø²ÎÊý£º
class Dec(object):
def __init__(self, i):
self.i = i
def __call__(self, func):
def inner_func(a, b, c):
return self.i * func(a, b, c)
return inner_func
@Dec(2)
def abc(x, y, z):
print "function abc"
print (x, y, z)
return x + y + z ......
1.³£Ó÷½·¨£¬²»´ø²ÎÊý
def decator(func):
def inner_func(*args):
args = (i * 2 for i in args)
return func(*args)
return inner_func
@decator
def add(a, b, c):
return a + b + c
2.´ø²ÎÊý£º
class Dec(object):
def __init__(self, i):
self.i = i
def __call__(self, func):
def inner_func(a, b, c):
return self.i * func(a, b, c)
return inner_func
@Dec(2)
def abc(x, y, z):
print "function abc"
print (x, y, z)
return x + y + z ......
Ôõôͨ¹ýODBCʹÓÃwxWidgetsÁ¬½ÓAccessÊý¾Ý¿â
1¡¢wxWidgets¿âÖÐODBCµÄ±àÒë
ĬÈϱàÒëʱ£¬ODBC¿âÖеÄûÓе¼³ö£¬ÖÂʹµ÷ÓÃwxDbConnectInf£¬wxDbTableµÈÀຯÊýÊÇʱ³öÏÖÁ´½Ó´íÎóµÄÎÊÌ⣬¹ÊÊ×ÏÈÒª±àÒëODBC¿âΪµ¼³ö Àà¿â£¬ÕâÐèÒªÔÚ"Include"Ŀ¼ÏµÄ"Setup.h"ÖжÔ#define wxUSE_ODBC 0ÉèÖÃΪ1£¬ÖØÐ±àÒë¼´¿É.
2¡¢Êý¾Ý¿âµÄÁ´½ÓÓëÊý¾ÝµÄ¶ÁÈ¡
//Æô¶¯ºÍÅäÖÃÊý¾Ý¿â»·¾³
wxDbConnectInf *ConnectConfig = new wxDbConnectInf(NULL, wxT("DB1"), wxT(""), wxT("")); //(DB1¾ÍÊÇODBCÊý¾ÝÔ´) //Á´½ÓÊý¾Ý¿â
wxDb *theConnect = wxDbGetConnection(ConnectConfig);
//±íµÄ´ò¿ª
wxDbTable *tbl = new wxDbTable(theConnect,wxT("S1"),2,wxT(""), !wxDB_QUERY_ONLY, wxT("")); //(S1¾ÍÊÇDB1ÖеıíÃû)
//Êý¾ÝºÍ±äÁ¿°ó¶¨(ID,theNameÊDZíÖеÄ×ֶΣ¬ theID,theName¾ÍÊÇÀ¦°óÊý¾Ý)
tbl->SetColDefs(0, wxT("ID"), DB_DATA_TYPE_INTEGER, &theID, SQL_C_LONG, sizeof(theID), false, true);
tbl->SetColDefs(1, wxT("theName"), DB_DATA_TYPE_VARCHAR, theName, SQL_C_WXCHAR, sizeof(theName), false, true);
//ÅжÏÊÇ·ñÕýÈ·´ò¿ª±í
if (!tbl->Open()) { ......