V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
123s
V2EX  ›  Python

py 新人, print 死活不知道哪里错

  •  
  •   123s · 2017-03-20 09:27:36 +08:00 · 1948 次点击
    这是一个创建于 2594 天前的主题,其中的信息可能已经有所发展或是发生改变。
    import os
    from multiprocessing import Process
    
    def child_proc(name): 
        print "Run child process %s (%s)..." % (name, os.getpid())
    
    if __name__ == '__main__':
        print "Parent process %s." % (os.getpid())
        p = Process(target=child_proc, args=('test',))
        print 'Process will start.'
        p.start()
        p.join()
        print 'Process end.'
    
      File "r.py", line 5
        print "Run child process %s (%s)..." % (name, os.getpid())
                                           ^
    SyntaxError: invalid syntax
    

    格式化有问题吗,看不出来啊

    zhangshine
        1
    zhangshine  
       2017-03-20 09:37:20 +08:00
    Python 什么版本?
    123s
        2
    123s  
    OP
       2017-03-20 09:39:41 +08:00
    eloah
        3
    eloah  
       2017-03-20 09:43:11 +08:00   ❤️ 1
    ......py3 里面 print 已经是一个函数了
    D3EP
        4
    D3EP  
       2017-03-20 09:43:40 +08:00 via Android
    print()
    123s
        5
    123s  
    OP
       2017-03-20 09:44:07 +08:00
    @eloah 懂了..
    123s
        6
    123s  
    OP
       2017-03-20 09:44:31 +08:00
    @eloah 你也 在珠海啊
    wohenyingyu02
        7
    wohenyingyu02  
       2017-03-20 09:44:49 +08:00
    请看 python3 入门教材第一页的 hello world 程序就知道了
    ytmsdy
        8
    ytmsdy  
       2017-03-20 10:28:43 +08:00 via iPhone
    这是 2.7 的写法!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1021 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 22:59 · PVG 06:59 · LAX 15:59 · JFK 18:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.