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='\n', 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
Python print "hello world" SyntaxError: invalid syntax的更多相关文章
- Python 的print报错SyntaxError: invalid syntax
1. #!/usr/bin/python print "hello world!" print报错:SyntaxError: Missing parentheses in call ...
- python d:\test.py File "<stdin>", line 1 python d:\test.py ^ SyntaxError: invalid syntax
pyhton出错: python d:\test.py File "<stdin>", line 1 python d:\test.py ^SyntaxError: i ...
- Python 3.6print 出现 SyntaxError: invalid syntax
开始使用sublime学习python,编写代码如图 Ctrl+B运行以后,报错 SyntaxError: invalid syntax 百度查询以后,大部分的回答都是说,python在3.0以后 ...
- python json.dumps(output) ^ SyntaxError: invalid syntax
问题 下面代码在有些机器上执行正常,有些机器上执行报错: import json output={} print json.dumps(output) python代码报错: line 277 pri ...
- python 3.4.0 简单的print 'hello world',出错--SyntaxError: invalid syntax
问题描写叙述: win7下安装的python 3.4.0版本号, 在命令行里写入简单的输出语句: print 'hello world' 然后enter,结果返回结果为: SyntaxError: i ...
- Centos中Python升级为3.X时yum出现except OSError, e: ^ SyntaxError: invalid syntax问题 No module named 'pip._internal.main
CentOS 7升级Python到3.7.2后,需要在/usr/bin/python创建了一个指向Python 3的软连接,然后将/usr/bin/yum的顶部的: !/usr/bin/python ...
- 使用python pip安装工具组件包:出现 requests File “<stdin>",line 1 pip install xxx ^ SyntaxError:invalid syntax
最近想要试试python ,软件安装完成了,但是,import 组件包时,出了问题,一直不得解:安装pycharm 工具感觉麻烦,不想安装那些,只想单纯使用python . 问题复现: 1.Windo ...
- python import错误 SyntaxError: invalid syntax
导入一个叫service-listener.py的文件是一直遇到错误: SyntaxError: invalid syntax 单独运行service-listener这个文件时,没有问题,只是不能被 ...
- 解决无法运行Terminator出现以下问题: File "/usr/bin/terminator"...SyntaxError: invalid syntax
在安装或者启动Terminator时可能出现这个问题: lin@Dev:~$ terminator File "/usr/bin/terminator", line 123 exc ...
随机推荐
- OOP 2.2 构造函数
1.概念 成员函数的一种 名字与类名相同,可以有参数,没有返回值(void也不行) 作用:对对象进行初始化,如给成员函数赋初始值 如果定义时没有构造函数,则编译器生成一个默认无参数的构造函数 默认构造 ...
- 404 Note Found队——现场编程
目录 组员职责分工 github 的提交日志截图 程序运行截图 程序运行环境 GUI界面 基础功能实现 运行视频 LCG算法 过滤(降权)算法 算法思路 红黑树 附加功能一 背景 实现 附加功能二(迭 ...
- 关于虚拟机安装mac os 教程详解
环境搭建 VMware下载 百度云盘下载:链接:http://pan.baidu.com/s/1pK8RcLl 密码:5jc5 Unlocker208 百度云盘下载:链接:http://pan.bai ...
- 在pycharm中使用scrapy爬虫
目标在Win7上建立一个Scrapy爬虫项目,以及对其进行基本操作.运行环境:电脑上已经安装了python(环境变量path已经设置好), 以及scrapy模块,IDE为Pycharm .操作如下: ...
- 如何解决Unsupported Architecture. Your executable contains unsupported architecture '[x86_64, i386]
APP改版测试后准备Archive发布时,结果居然出现题目中的错误提示.查了一下,如果archive的时候没有选[iOS](http://lib.csdn.net/base/ios) Devices ...
- vsftpd 安全性能工具
vsftpd实战(服务端192.168.23.12,客户端192.168.23.11) 1:安装vsftpdyum install -y vsftpd 2:客户端安装lftpyum install - ...
- QMultiMap使用
版权声明:若无来源注明,Techie亮博客文章均为原创. 转载请以链接形式标明本文标题和地址: 本文标题:QMultiMap使用 本文地址:http://techieliang.com/201 ...
- eclipse生成jar包 注意事项!
原文转自:http://www.cnblogs.com/zhangfei/archive/2013/01/22/2871075.html 第一:普通类导出jar包,我说的普通类就是指此类包含main方 ...
- jenkin重新注册用户
http://www.cnblogs.com/xiao-fy/
- kafka describe 显示结果解释
> bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic my-replicated-topic Topic:my- ...