1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| # -*- coding: UTF-8 -*- import MySQLdb as mdb import time import random
a1=(2010,12,29,0,0,0,0,0,0) a2=(2019,5,31,23,59,59,0,0,0)
start=time.mktime(a1) end=time.mktime(a2)
for i in [7,8,9,10,11,16]: t=random.randrange(start,end) date_touple=time.localtime(t) date=time.strftime("%Y-%m-%d %H:%M:%S",date_touple)? timeArray = time.strptime(date, "%Y-%m-%d %H:%M:%S") timestamp = int(time.mktime(timeArray)) print timestamp conn = mdb.connect('数据库服务器ip','数据库用户名','数据库密码','数据库名') cur = conn.cursor() cur.execute("update typecho_contents set created = %s where cid = %s"%(timestamp,i))
|