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‘. 正解相关推荐

  1. python 错误之SyntaxError: Missing parentheses in call to 'print'

    SyntaxError: Missing parentheses in call to 'print' 由于python的版本差异,造成的错误. python2: print "hello ...

  2. SyntaxError: Missing parentheses in call to 'print' 这个错误原因是Python版本问题

    问题 print "www.baidu.com"           Python2 print ("www.baidu.com")     Python3 出 ...

  3. 问题记录:SyntaxError: Missing parentheses in call to ‘print‘.

    scripts/kconfig/conf --silentoldconfig Kconfig   CHK     include/config.h   GEN     include/autoconf ...

  4. Python SyntaxError: Missing parentheses in call to 'print'

    下面的代码 print "hello world" 会出现下面的错误 SyntaxError: Missing parentheses in call to 'print' 因为写 ...

  5. 解决 Python 报错SyntaxError: Missing parentheses in call to 'print'

    报错:SyntaxError: Missing parentheses in call to 'print' 解析: python2.X版本与python3.X版本输出方式有点不同,在2.X中直接输出 ...

  6. 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. ...

  7. SyntaxError: Missing parentheses in call to ‘print‘. Did you mean print(e)?

    在学习古月老师ROS第四课,启动机器人的键盘控制launch文件时报了这个error,下面是报错的内容: process[mbot_teleop-1]: started with pid [4942] ...

  8. 使用print时出错 SyntaxError: Missing parentheses in call to ‘print‘ Did you mean print(““)

    使用print时出错 SyntaxError: Missing parentheses in call to 'print' Did you mean print("") 错误原因 ...

  9. SyntaxError: Missing parentheses in call to 'print'

    在笨方法学python 中,有时候我们使用print打印时,会输出如下错误: Missing parentheses in call to 'print' 原因:这是因为我们使用python3.0的语 ...

最新文章

  1. 2022-2028年中国安防行业研究及前瞻分析报告
  2. oVirt 3.4.3-1 LiveCD ISO based on CentOS 6.5
  3. cpu使用率 htop显示_Linux查看CPU和内存使用情况
  4. 【原创】完美实现GetProcAddress [文字模式]
  5. linux tasklet函数,14.9.5 实例:Tasklet演示
  6. 10.1.3 标签分类与嵌套
  7. tensorflow 之 最近用到的几个小操作tf.reshape,tf.convert_to_tensor,tf.where
  8. Mysql数据库常用指令
  9. 数学--数论--HDU1825(积性函数性质+和函数公式+快速模幂+非互质求逆元)
  10. 这一新的可视化方法教你优雅地探索相关性
  11. java基础----变量与常量+作用域
  12. 团队作业2之选题与评审
  13. 在vs2010中mfc,C++的一些小经验
  14. 项目使用mybatis-plus采用mysql/clickhouse多数据库配置,报错Invalid bound statement (not found)
  15. 论文模型图全攻略——模型图就该有模型图的样子!
  16. GEF 命令模式介绍
  17. 【C++】Vscode 中使用CMakeLists(推荐)构建C++项目:项目结构、各个文件夹的作用、从编码到debug
  18. springboot中static下的图片404
  19. uni 讯飞文字转语音 详解
  20. 如何识别一张图片中的字体,并复刻

热门文章

  1. 一个简单的Hello World程序
  2. 基于python和高德地图租房系统的设计与实现
  3. 在mtk移植个linux内核,移植 Linux Kernel 造成無法開機之解決方案以及除錯工具
  4. S3DIS数据集的几个bug
  5. ubuntu下docker的lnmp(二) 安装php-fpm之 下载镜像启动容器
  6. Redis 50问
  7. Android重写ImageView实现图片镜像效果
  8. 正则表达式中的方法、检测、特殊字符、敏感词替换等等
  9. 你应该了解真相_世界首次了解核风险的真相
  10. FFmpeg入门详解之12:Elecard Stream Analyzer码流分析工具