- 帖子
- 1
- 精华
- 0
- 积分
- 6
- 阅读权限
- 10
- 注册时间
- 2016-3-17
- 最后登录
- 2016-3-19
|
crossin老师好,
我用的是mac系统,在terminal用 python web.py编译出现以下问题,但是用IDLE没有问题
web.py:
# -*- coding: utf-8 -*-
import urllib2
import json
from city import city
cityname=raw_input('你想查哪个城市的天气?\n')
ctycode=city.get(cityname)
if citycode:
url=('http://www.weather.com.cn/data/cityinfo/%s.html'%citycode)
content = urllib2.urlopen(url).read()
print content
报错:
Traceback (most recent call last):
File "web.py", line 2, in <module>
import urllib2
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 94, in <module>
import httplib
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1151, in <module>
import ssl
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 58, in <module>
import textwrap
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/textwrap.py", line 40, in <module>
class TextWrapper:
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/textwrap.py", line 82, in TextWrapper
whitespace_trans = string.maketrans(_whitespace, ' ' * len(_whitespace))
AttributeError: 'module' object has no attribute 'maketrans' |
|