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
相关文档:
一般安装的都是Python22版,wincvs1.3需要python2.1版本及以上。但是启动过程找不到,网上搜索的方法不大适用。最后经过试验发现,把Python22安装路径下的python22.dll拷贝到wincvs的安装目录下。运行wincvs,ok。觉得这个方法好用的给顶下! ......
Python的字典操作
Python提供了多种应用于字典的操作。因为字典为容器,内建len函数可以将字典当作单一参数使用听切返回字典对象中项目(键/值对)的数目。
字典会员
在Python2.2以及后面版本,D中的k运算符检测是否对象k是字典D中的键。如果是返回True如果不是返回False。相似的,
索引一个字典
字典D中的值 ......
在Python中有一个非常重要也非常好用的模块re,在import re后,就能够在Python中使用正则表达式,源于此次项目要用正则表达式对html代码提取一定的字符,所以在这也就用些小例子来熟悉一下正则表达式
现在就用最简单的例子
import re
s='<title>http://www.baidu.com</title>'
print re.findall(r'&l ......
最近要用到串口通讯,简单易用的Python又帮上忙了,多亏了庞大的第三方资源~~~ :)
pySerial
Overview
This module encapsulates the access for the serial port. It provides
backends for Python running on Windows, Linux, BSD (possibly any POSIX
compliant system), Jython and IronPython (.NET and M ......