Missing parentheses in call to 'print' Python初学
来源:互联网 发布:国家卫生系统网络直报 编辑:程序博客网 时间:2024/06/05 19:55
最近在学习自动化测试,Python无疑成了必学的脚本语言,去图书馆借几本书打算小小的研究一下,随手敲上第一个hello world
没想到第一个代码就不能运行~ORZ
两种方法:此方法也可以测试你的电脑上Python环境有没有部署好。
第一:桌面新建一个记事本文件,输入
print "hello world"
raw_input("hit enter to continue")
保存后缀名改成 XX.py
然后双击运行。但是我这里出现闪退现象。是因为语法错误:
Missing parentheses in call to 'print'
原来是因为Python2.X和Python3.X不兼容。
我安装的是Python3.X,但是我试图运行的却是Python2.X 的代码。
所以上面的语法在python3中是错误的。在python3中,你需要将print后面的语句加括号,正确的写法:
print ("hello world")
raw_input("hit enter to continue")
另外这里的raw_input 也会提示 raw_input is not defined 还是上面的版本问题,
input 和从前的 raw_input 等效。唉,果断换。
第二:从命令行运行Python 程序
开始菜单下------cmd
由于python文件是建在桌面上的,需要cd Desktop 切换到目录到桌面,然后输入XX.py
在命令行里运行python 程序的好处是可以看到错误信息,而不是绝情的闪退~~~
以上。
0 0
- Missing parentheses in call to 'print' Python初学
- 【Python】 Missing parentheses in call to 'print'
- 【Python】 Missing parentheses in call to 'print'
- 【Python】 Missing parentheses in call to 'print'
- 【PYTHON】 Missing parentheses in call to 'print'
- 【Python】 Missing parentheses in call to 'print'
- 【python】print "hello" SyntaxError: Missing parentheses in call to 'print'
- Python之print "hello" SyntaxError: Missing parentheses in call to
- 【Python】SyntaxError: Missing parentheses in call to 'print'
- python:SyntaxError:Missing parentheses in call to 'print'
- 解决python 提示 SyntaxError: Missing parentheses in call to 'print'
- 【python】]SyntaxError: Missing parentheses in call to 'print'
- 解决python 提示 SyntaxError: Missing parentheses in call to 'print'
- Missing parentheses in call to 'print'——python语法错误
- Missing parentheses in call to 'print'
- SyntaxError: Missing parentheses in call to 'print'
- SyntaxError:Missing parentheses in call to 'print'
- SyntaxError: Missing parentheses in call to 'print'
- SuperMap iDesktop 自动化制图
- K均值聚类--利用k-means算法分析NBA近四年球队实力
- 程序猿攀登的高峰:九寨沟,黄山,华山,泰山,普陀山,云台山
- 利用php判断是否为手机端的方法
- leetcode
- Missing parentheses in call to 'print' Python初学
- Convolution Neural Network (CNN) 原理与实现
- python基础学习网址
- App移动端项目管理
- 哪个版本的gcc才支持c11
- 简单的用户登录页面与后台数据库的交互
- java中的静态代理
- 移动端App开发流程管理
- Apache-apollo(windows下的搭建)