SyntaxError: Missing parentheses in call to ‘print‘. 正解
SyntaxError: Missing parentheses in call to 'print'. 报错是由于Python3和Python2版本不同,print函数语法也不同造成的。这样的原因很可能是用Python3跑了Python2 的程序。所以这种问题有两种方法解决。
第一种:更换Python版本(默认ubuntu终端)
首先输入Python查看Python版本,如果是Python3,则将语句改成Python2+执行的命令即可。以古月居的程序为例
for a in range(5, 10):
if a < 10:
print 'a = ', a
a += 1
else:
break
当输入python python_for.py时报错:SyntaxError: Missing parentheses in call to 'print'. Did you mean print('a = ', a)?
当输入:python2 python_for.py时可以顺利跑出来
第二种方法:修改程序
将程序print变成print()即
for a in range(5, 10):
if a < 10:
print ('a = ', a)
a += 1
else:
break
也可以顺利跑通
SyntaxError: Missing parentheses in call to ‘print‘. 正解相关推荐
- python 错误之SyntaxError: Missing parentheses in call to 'print'
SyntaxError: Missing parentheses in call to 'print' 由于python的版本差异,造成的错误. python2: print "hello ...
- SyntaxError: Missing parentheses in call to 'print' 这个错误原因是Python版本问题
问题 print "www.baidu.com" Python2 print ("www.baidu.com") Python3 出 ...
- 问题记录:SyntaxError: Missing parentheses in call to ‘print‘.
scripts/kconfig/conf --silentoldconfig Kconfig CHK include/config.h GEN include/autoconf ...
- Python SyntaxError: Missing parentheses in call to 'print'
下面的代码 print "hello world" 会出现下面的错误 SyntaxError: Missing parentheses in call to 'print' 因为写 ...
- 解决 Python 报错SyntaxError: Missing parentheses in call to 'print'
报错:SyntaxError: Missing parentheses in call to 'print' 解析: python2.X版本与python3.X版本输出方式有点不同,在2.X中直接输出 ...
- python报错系列(9)--SyntaxError: Missing parentheses in call to ‘print‘. Did you mean print()
系列文章目录 文章目录 系列文章目录 前言 1.SyntaxError: Missing parentheses in call to 'print'. Did you mean print() 2. ...
- SyntaxError: Missing parentheses in call to ‘print‘. Did you mean print(e)?
在学习古月老师ROS第四课,启动机器人的键盘控制launch文件时报了这个error,下面是报错的内容: process[mbot_teleop-1]: started with pid [4942] ...
- 使用print时出错 SyntaxError: Missing parentheses in call to ‘print‘ Did you mean print(““)
使用print时出错 SyntaxError: Missing parentheses in call to 'print' Did you mean print("") 错误原因 ...
- SyntaxError: Missing parentheses in call to 'print'
在笨方法学python 中,有时候我们使用print打印时,会输出如下错误: Missing parentheses in call to 'print' 原因:这是因为我们使用python3.0的语 ...
最新文章
- 2022-2028年中国安防行业研究及前瞻分析报告
- oVirt 3.4.3-1 LiveCD ISO based on CentOS 6.5
- cpu使用率 htop显示_Linux查看CPU和内存使用情况
- 【原创】完美实现GetProcAddress [文字模式]
- linux tasklet函数,14.9.5 实例:Tasklet演示
- 10.1.3 标签分类与嵌套
- tensorflow 之 最近用到的几个小操作tf.reshape,tf.convert_to_tensor,tf.where
- Mysql数据库常用指令
- 数学--数论--HDU1825(积性函数性质+和函数公式+快速模幂+非互质求逆元)
- 这一新的可视化方法教你优雅地探索相关性
- java基础----变量与常量+作用域
- 团队作业2之选题与评审
- 在vs2010中mfc,C++的一些小经验
- 项目使用mybatis-plus采用mysql/clickhouse多数据库配置,报错Invalid bound statement (not found)
- 论文模型图全攻略——模型图就该有模型图的样子!
- GEF 命令模式介绍
- 【C++】Vscode 中使用CMakeLists(推荐)构建C++项目:项目结构、各个文件夹的作用、从编码到debug
- springboot中static下的图片404
- uni 讯飞文字转语音 详解
- 如何识别一张图片中的字体,并复刻