linux中国网

linux菜菜鸟的日记

python异常处理举例

# -*- coding: utf-8 -*-
import sys ,os
db_host="192.168.1.200"
db_user="root"
db_passwd="123456"
db_charset="utf8"
actor = "eva"
zone="t5"
db_backup_name = "my.sql"
#print db_backup_name
try:
    mysqldump = r"mysqldump.exe"
    os.system(mysqldump+" -a --add-locks -C -c -x -R -h%s -u%s -p%s %s%s --default_character-set=%s > %s" %(db_host, db_user, db_passwd, actor, zone, db_charset, db_backup_name))
except  Exception,e:
    print u" mysqldump数据库失败:",e

http://www.cnblogs.com/dkblog/archive/2011/06/24/2089026.html

评论已关闭。