设为首页收藏本站

Crossin的编程教室

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

集中答疑专用贴

  [复制链接]

0

主题

0

好友

14

积分

新手上路

Rank: 1

楼主
发表于 2017-8-30 14:55:57 |显示全部楼层

不知道哪里错了?

回复

使用道具 举报

0

主题

0

好友

14

积分

新手上路

Rank: 1

沙发
发表于 2017-8-30 14:56:40 |显示全部楼层
小白森 发表于 2017-8-30 14:55
不知道哪里错了?


回复

使用道具 举报

0

主题

0

好友

14

积分

新手上路

Rank: 1

板凳
发表于 2017-8-30 15:09:11 |显示全部楼层
图片上传了,显示不了。下面是代码和报错的内容。
#-*-coding:utf-8 -*-
import urllib2
import json
from city import city
print '你想查询哪个城市的天气?/n'
city_name=raw_input()
city_code=city.get(city_name)
if city.code:
   url=('http://www.weather.com.cn/data/cityinfo/%s.html' % citycode)
   content=urllib2.urlopen(url).read()
   print content

报错
Traceback (most recent call last):
  File "C:\Users\feiwen_fan\Desktop\weather-fail.py", line 5, in <module>
    from city import city
ImportError: No module named city
>>>

之前报错还不是这样的,提示SyntaxError: Non-ASCII character。。。
回复

使用道具 举报

0

主题

0

好友

14

积分

新手上路

Rank: 1

地板
发表于 2017-8-30 17:12:15 |显示全部楼层
小白森 发表于 2017-8-30 15:09
图片上传了,显示不了。下面是代码和报错的内容。
#-*-coding:utf-8 -*-
import urllib2

city.py之前被我移到了另一个文件夹中,所以报错
Traceback (most recent call last):
  File "C:\Users\feiwen_fan\Desktop\weather-fail.py", line 5, in <module>
    from city import city
ImportError: No module named city
>>>
我把文件移到同一个路径下,报错
Traceback (most recent call last):
  File "C:\Users\feiwen_fan\Desktop\weather-fail.py", line 6, in <module>
    from city import city
  File "C:\Users\feiwen_fan\Desktop\city.py", line 2
SyntaxError: Non-ASCII character '\xe5' in file C:\Users\feiwen_fan\Desktop\city.py on line 2, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
>>>
回复

使用道具 举报

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

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

GMT+8, 2024-5-5 13:11 , Processed in 0.030019 second(s), 22 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部