推荐学习书目
› 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 · 4010 views
    This topic created in 4095 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   ·   Privacy   ·   Solana   ·   827 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 19:27 · PVG 03:27 · LAX 12:27 · JFK 15:27
    ♥ Do have faith in what you're doing.