对于 出现Missing parentheses in call to ‘print’和’raw_input’ is not defined问题的解决

对于 出现Missing parentheses in call to ‘print’和’raw_input’ is not defined问题的解决

在学习Python的过程中,我安装的是最新版本3.6

以前因为感兴趣对Python对Python的学习是基于2.0版本的,这次换成3.0版本的,出现了出现Missing parentheses in call to ‘print’和’raw_input’ is not defined问题

print‘hello world’
出现错误SyntaxError: Missing parentheses in call to ‘print’
后改成print(‘hello world’)可正确输出

原来python从3.0后将print变为一个函数,所以需要加上括号,从那时开始,我就发觉,python学习过程中,肯定还会有好多版本问题,今天又遇到一个

NameError: name ‘raw_input’ is not defined

后来发现,3.0以后把raw_input变成了input,一步一步来,总有搞定的一刻,期待!


还有就是python中的缩进是重要的一部分,要习惯使用一种缩进方式,以免造成程序不必要的bug!

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Missing parentheses in call to 'print'是一个语法错误,意味着在调用print函数时缺少了括号。这个错误通常是因为在Python3中使用了Python2的print语法。在Python3中,print函数应该用括号包围起来,例如print('a = ', a)。为了解决这个问题,有两种方法可以采用。一种是将Python2的代码改写成Python3的语法,将print语句改为print函数,并在括号中传入要打印的内容。另一种方法是在Python3中使用Python2的语法,可以通过在代码的开头添加"from __future__ import print_function"来实现。这样可以使Python3解释器兼容Python2的print语法。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [SyntaxError: Missing parentheses in call to ‘print‘. 正解](https://blog.csdn.net/weixin_45653050/article/details/107306665)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [SyntaxError: Missing parentheses in call to 'print'.](https://blog.csdn.net/blog_yue/article/details/103205368)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值