V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
ecapsul
V2EX  ›  Python

python3 求助

  •  
  •   ecapsul · Jul 17, 2015 · 3642 views
    This topic created in 3950 days ago, the information mentioned may be changed or developed.

    初学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 replies    2015-07-17 12:39:44 +08:00
    bidu
        1
    bidu  
       Jul 17, 2015
    print(getHtml('http://tieba.baidu.com'))试试?
    Sylv
        2
    Sylv  
       Jul 17, 2015 via iPhone   ❤️ 1
    Python 3 要用 print(getHtml('http://tieba.baidu.com'))
    print 不加括号是 Python 2 的语法
    ecapsul
        3
    ecapsul  
    OP
       Jul 17, 2015
    了解了,谢谢各位
    jas0ndyq
        4
    jas0ndyq  
       Jul 17, 2015
    doge
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   6253 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 51ms · UTC 03:09 · PVG 11:09 · LAX 20:09 · JFK 23:09
    ♥ Do have faith in what you're doing.