zoukankan      html  css  js  c++  java
  • Python print "hello world" SyntaxError: invalid syntax

    刚安装Python,在IDLE中输入print “Hello World”,谁知却发生错误:

    >>> print "Hello World"
    SyntaxError: invalid syntax

    而在朋友的机子上测试却运行无误,经查得知这是Python 版本不同所致。朋友用的是2.x版本,而我用的是3.x版本

    正确命令:print("Hello World")

    问题是通过用help命令解决的。输入help(print)就知道print的正确用法了。

    >>> help(print)Help on built-in function print in module builtins:
    print(...)    print(value, ..., sep=' ', end=' ', file=sys.stdout, flush=False)        Prints the values to a stream, or to sys.stdout by default.    Optional keyword arguments:    file:  a file-like object (stream); defaults to the current sys.stdout.    sep:   string inserted between values, default a space.    end:   string appended after the last value, default a newline.    flush: whether to forcibly flush the stream.

    2013-07-26 15:13:28

     

     

  • 相关阅读:
    邮件发送工具类
    redis在项目中配置
    搭建zookeeper集群
    activeMQ安装
    solr安装配置中文分词IK
    reids安装
    jdk/tomcat/mysql在linux下安装
    使用poi进行excel导入
    linux 大杂烩
    找包网址
  • 原文地址:https://www.cnblogs.com/cszlg/p/3217164.html
Copyright © 2011-2022 走看看