python SyntaxError: Missing parentheses in call to 'print'. Did you mean print(a+b)?
时间: 2024-06-09 07:05:55 浏览: 29
Python中的语法错误SyntaxError: Missing parentheses in call to 'print'通常是因为在调用print函数时忘记了使用括号。正确的写法应该是print(),括号内可以是要打印的内容或变量。在你的错误信息中,建议你是否想要打印的是print(a b),如果是的话,你应该在a和b之间添加逗号,即print(a, b)。这样就能解决这个语法错误了。
相关问题
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(asd)?
这个错误提示是因为在Python3中,print函数需要加上括号,而你的代码中没有加上括号。正确的写法应该是print(asd)。如果你想在Python2中使用print语句,则不需要加上括号。下面是两个版本的代码示例:
Python3版本:
```python
print(asd) # 正确写法
print asd # 错误写法
```
Python2版本:
```python
print asd # 正确写法
print(asd) # 错误写法
```
SyntaxError: Missing parentheses in call to 'print'. Did you mean print
这个错误是由于在Python3中,print函数需要使用括号,而在Python2中则不需要。因此,如果你在Python3中运行Python2的代码,就会出现这个错误。解决这个问题的方法有两种:
1.在print函数中添加括号,例如:
```python
print('Hello, world!')
```
改为:
```python
print('Hello, world!')
```
2.将Python2的代码转换为Python3的代码。可以使用2to3工具来自动完成这个过程,也可以手动修改代码。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)