我的python脚本:
import ftplib
import hashlib
import httplib
import pytz
import datetime
import urllib
import os
import glob
def ftphttp():
localtime = datetime.datetime.now(tz=pytz.utc).isoformat()
cam = "002"
lscam = localtime + cam
ftp = ftplib.FTP('localhost','kevin403','S$ip1234')
ftp.cwd('/var/www/html/image')
m=hashlib.md5()
m.update(lscam)
dd=m.hexdigest()
for image in glob.glob(os.path.join('Desktop/images/*.png')):
with open(image, 'rb') as file:
ftp.storbinary('STOR '+dd+ '.png', file)
x = httplib.HTTPConnection('localhost', 8086)
x.connect()
f = {'ts' : localtime}
x.request('GET','/camera/store?cam='+cam+'&'+urllib.urlencode(f)+'&fn='+dd)
y = x.getresponse()
z=y.read()
x.close()
ftp.quit()
我想从文件属性中获取时间,因为我不希望它从我发送的时间开始。有谁可以帮我这个?
答案 0 :(得分:0)
@Alvin,您无法直接从 getmtime 获取 ISOdatetime ,如果您想从 getmtime 转换输出日期,您可以这样做以下方式:
dlmwrite
输出例如:' 2016-02-16T23:32:06.260088-05:00'对于美国/东方'时区