python 处理时间 import time import re now = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()) timeobj = re.match(r'(.*)-(.*)-(.*) (.*):(.*):(.*)', now) if timeobj is not None: timestamp = time.mktime(time.strptime(now, "%Y-%m-%d %H:%M:%S")
当我们这样建立文件时 f = file('x1.txt', 'w') f.write(u'中文') f.colse() 直接结果应该是类似 f.write(u'中文') UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-16: ordinal not in range(128) 要直接写 utf-8 文件怎么办呢? import codecs f = codecs.open("pru_uni.txt&q
import smtplib from operator import itemgetter, attrgetter from email.mime.text import MIMEText from email.header import Header from email.mime.multipart import MIMEMultipart from email.utils import COMMASPACE,formatdate to = ['wangquanjun@xxx.com']