URL特别字符处理

import time,os,datetime
import urllib3
utcNow = datetime.datetime.utcnow()
fifteen = utcNow +datetime.timedelta(minutes=-15)


timestr = fifteen.strftime('%Y-%m-%dT%H:%M:%S.%f.Z')

query = '{"_lastInform:":{"$gt":"%s"}}'% timestr

print(query)

import urllib

query = urllib.parse.quote(query)
# datetime.timedelta(minutes=15)

result = urllib.parse.unquote(query)

print(result)
posted @ 2019-04-11 14:25  雷神约  阅读(146)  评论(0编辑  收藏  举报