Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

python os Ä£¿é

Python 3 ½Ì³Ì¶þ:Îļþ,Ŀ¼ºÍ·¾¶
http://www.cnitblog.com/yunshichen/archive/2009/04/01/55931.html
python osÄ£¿é
http://hi.baidu.com/happynp/blog/item/729243f902d5a751242df2c2.html
http://hi.baidu.com/fiber212121/blog/item/6e07ec03c97b6982d53f7c27.html
python getoptÄ£¿é
http://www.tsnc.edu.cn/default/tsnc_wgrj/doc/pythonhtml/html/scripts_and_streams/command_line_arguments.html
http://www.sqlite.com.cn/MySqlite/11/416.Html
http://docs.python.org/library/getopt.html
http://docs.python.org/library/optparse.html
mysqldbback.py
#!/usr/bin/python
import os
import time
import ftplib
import traceback
#config vars
systempathchr="/" #·¾¶·Ö¸î·û£¬*nixÓÃ"/" win32ÓÃ"\\"
dbuser="root" #Êý¾Ý¿âÓû§Ãû
dbpwd="dbpwd" #Êý¾Ý¿âÃÜÂë
dbnamelist=["dbone","dbtwo","dbthree"] #ÐèÒª±¸·ÝÄÇЩÊý¾Ý¿â
workdir="/path/to/backup/" #±¾µØ±¸·ÝÎļþ¼Ð
errlogfile="databack.log" #´íÎóÈÕÖ¾Ãû
ftp_addr="192.168.0.2" #ftpµØÖ·
ftp_port="2102" #ftp¶Ë¿Ú
ftp_user="databack" #ftp̞
ftp_pwd="backpwd" #ftpÃÜÂë
ftp_path="/" #´æ·Åµ½ftp·¾¶
ftpqueue=[]
def ftpstor():
#login
bufsize=1024
ftp=ftplib.FTP()
try:
ftp.connect(ftp_addr,ftp_port)
ftp.login(ftp_user,ftp_pwd)
ftp.cwd(ftp_path)
for filepath in ftpqueue:

#open file for input as binary
f=open(filepath,"rb")
#store file as binary
print getfilename(filepath)
ftp.storbinary("STOR "+getfilename(filepath),f,bufsize)
f.close()
ftp.quit()
except:
path=os.path.join(workdir,errlogfile)
traceback.print_exc(file=open(path,"a"))

def dumpdb(dbname):
global ftpqueue
timeformat="%Y%m%d"
sqlvalformat="mysqldump -u%s -p\"%s\" \"%s\" >\"%s


Ïà¹ØÎĵµ£º

ÉîÈë GalCon£ºPython¡¢ÓÎÏ·¿ª·¢ºÍÈ˹¤ÖÇÄÜ

Alex. J. Champandard
ÀµÓºƣ¨http://laiyonghao.com£© Òë
Ô­ÎĵØÖ·£ºhttp://aigamedev.com/open/interviews/inside-galcon-python-ai/
AiGameDev.comÔÚÕâ¸öÖÜÒ»µÄ pratical insights ÊǶÔPhil Hassey²É·Ã¡£Phil ÊÇÒ»¸ö¶ÀÁ¢ÓÎÏ·¿ª·¢Õߣ¬Ò²ÊÇÓÎÏ·²úÒµÉçÇøµÄ»îÔ¾·Ö×Ó¡£ËûÔøÓ®µÃ2006Äê4Ô嵀 Ludum Dare ±ÈÈü£¨Õâ¸ö±ÈÈü¹Ø×¢ ......

Python & XML


Chapter 1
Python and XML
Python and XML are two very different animals, each with a rich
history. Python is a full-scale programming language that has grown
from scripting world roots in a very organic way, through the vision
and guidance of Python's inventor, Guido van Rossum. Guido continue ......

Python×Ö·û´®µÄencodeÓëdecode

 
Ê×ÏÈÒª¸ãÇå³þ£¬×Ö·û´®ÔÚPythonÄÚ²¿µÄ±íʾÊÇunicode±àÂ룬Òò´Ë£¬ÔÚ×ö±àÂëת»»Ê±£¬Í¨³£ÐèÒªÒÔunicode×÷ΪÖмä±àÂ룬¼´ÏȽ«ÆäËû±àÂëµÄ×Ö·û´®½âÂ루decode£©³Éunicode£¬ÔÙ´Óunicode±àÂ루encode£©³ÉÁíÒ»ÖÖ±àÂë¡£
decodeµÄ×÷ÓÃÊǽ«ÆäËû±àÂëµÄ×Ö·û´®×ª»»³Éunicode±àÂ룬Èçstr1.decode('gb2312')£¬±íʾ½«gb2312±àÂëµÄ×Ö· ......

²ËÄñѧPython£¨Ò»£©

   Ϊ³äʵ×Ô¼ºÄÇƽӹµÄ֪ʶ¿â£¬´Ó½ñÌ쿪ʼ£¬Ñ§Ï°PythonÓïÑÔ¡£   Ì«¸ßÉîµÄ×ÊÁÏ¿´²»¶®£¬µ±Á˱¾×î¼òµ¥µÄPython¼òÃ÷½Ì³Ì£¬ÖÐÎÄ°æchm¸ñʽµÄ¡£²»Ëµ·Ï»°ÁË£¬¿ªÊ¼½øÈëPythonµÄÊÀ½ç°É¡£ £¨Ò»£©°²×°Python    дÕâƪÎÄÕÂʱ£¬PythonµÄ×îа汾ÊÇ3.1£¬ÎÒϲ»¶ÓÃ×îеģ¬¾ÍÏÂÁËа汾µÄ¡£Ò»Â·NextÏÂÈ¥£¬ÎÒµÄC ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ