python2except : fp = StringIO.StringIO() #创建内存文件对象 traceback.print_exc(file=fp) message = fp.getvalue() sendMail=yiguoLibrary.mail() sendMail.send('淘宝客自动脚本错误','登录时报错\n'+str(message),toMail)
python3except Exception as e: fp=StringIO() traceback.print_exc(file=fp) message = fp.getvalue() print(message)
字典和list直接print中文 u''类型 str(list1).replace('u\'','\'').decode("unicode-escape") ''类型 str(list1).decode('string_escape') 获取字符编码 import chardet print chardet.detect(EnvType) 会得到{'confidence': 0.99, 'language': 'Chinese', 'encoding': 'GB2312'}
转载于:https://www.cnblogs.com/edwar172038/p/7598205.html
