- 帖子
- 5
- 精华
- 0
- 积分
- 16
- 阅读权限
- 10
- 注册时间
- 2018-3-11
- 最后登录
- 2018-3-19
|
老师,我用的是py3.6
我的代码:
# -*- coding: utf-8 -*-
from city import city
import urllib.request
import json
cityname = input('你想查哪个城市的天气?\n')
citycode = city.get(cityname)
if citycode:
url = ('http://www.weather.com.cn/data/cityinfo/%s.html' % citycode)
content = urllib.request.urlopen(url).read()
print(content)
结果报错:
File "C:\Users\shenwang886\Desktop\python\从网络中获取数据.py", line 10, in <module>
from city import city
File "C:\Users\shenwang886\Desktop\python\city.py", line 2
SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xb1 in position 0: invalid start byte
请问应该怎么改呢? |
|