设为首页收藏本站

Crossin的编程教室

 找回密码
 立即加入
楼主: crossin先生
打印 上一主题 下一主题

【Python 第44课】 查天气(2)

  [复制链接]

0

主题

0

好友

6

积分

新手上路

Rank: 1

楼主
发表于 2016-7-22 10:40:01 |显示全部楼层
老师老师我沉船了
为了节省咱的空间我就不发图直接发代码和结果
  1. <div># -*- coding:utf-8 -*-</div><div>import urllib2</div><div>import json</div><div>
  2. </div><div>from city import city</div><div>cityname = raw_input("你想查询哪个城市的的天气?\n")</div><div>citycode = city.get(cityname)</div><div>
  3. </div><div>if citycode:</div><div>    url = ('http://www.weather.com.cn/data/cityinfo/%s.html' % citycode)</div><div>    content = urllib2.urlopen(url).read()</div><div>    print content</div>
复制代码
完全一样的代码
  1. <div>Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on win32</div><div>Type "copyright", "credits" or "license()" for more information.</div><div>>>> ================================ RESTART ================================</div><div>>>> </div><div>
  2. </div><div>Traceback (most recent call last):</div><div>  File "D:/python/demo", line 5, in <module></div><div>    from city import city</div><div>  File "D:/python\city.py", line 2</div><div>SyntaxError: Non-ASCII character '\xe5' in file D:/python\city.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details</div><div>>>> </div>
复制代码
这个是运行结果~~求老师教教~

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即加入

QQ|手机版|Archiver|Crossin的编程教室 ( 苏ICP备15063769号  

GMT+8, 2024-5-18 14:24 , Processed in 0.025876 second(s), 23 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部