标签:数据类型转换 utf-8 response .text color city imp open bsp
import json
dict = {‘k1‘:‘v1‘}
result = json.dumps(dict)
print(result,type(result))
s1 = ‘{"k1":123}‘
dic = json.loads(s1)
print(dic,type(dic))
li = [11,22,33]
json.dump(li,open(‘b.txt‘,‘w‘))
li = json.load(open(‘b.txt‘,‘r‘))
print(type(li),li)
import requests
import json
response = requests.get(‘http://wthrcdn.etouch.cn/weather_mini?city=上海‘)
response.enconding = ‘utf-8‘
dic = json.loads(response.text)
print(dic,type(dic))
import pickle
li = [11,22,33]
r = pickle.dumps(li)
print(r)
result = pickle.loads(r)
print(result)
li = [11,22,33]
pickle.dump(li,open(‘b.txt‘,‘wb‘))
标签:数据类型转换 utf-8 response .text color city imp open bsp
原文地址:http://www.cnblogs.com/hanwei999/p/6159782.html