初学py3,
import urllib.request
def getHtml(url):
page=urllib.request.urlopen(url)
html=page.read()
return html
print getHtml('http://tieba.baidu.com')
运行提示出错,不知道错在哪儿,求教
print getHtml('http://tieba.baidu.com')
^
SyntaxError: invalid syntax
4 条回复 • 2015-07-17 12:39:44 +08:00
|
1
bidu 2015 年 7 月 17 日
print(getHtml('http://tieba.baidu.com'))试试?
|
|
2
Sylv 2015 年 7 月 17 日 via iPhone Python 3 要用 print(getHtml('http://tieba.baidu.com'))
print 不加括号是 Python 2 的语法 |
|
3
ecapsul OP 了解了,谢谢各位
|
|
4
jas0ndyq 2015 年 7 月 17 日
doge
|
推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide