我正在尝试学习python,并且出于某种原因我不断收到语法错误。当我审查我看到没有错误
操作系统版本:
[root@localhost python3.6]# cat /etc/*release
CentOS Linux release 7.5.1804 (Core)
版本:
[root@localhost python3.6]# python3.6 -V
Python 3.6.5
Python脚本: [root @ localhost python3.6] #cat ex8.py
formatter = "{} {} {} {}"
print(formatter.format(1, 2, 3, 4))
print(formatter.format("one", "two", "three", "four")
print(formatter.format(True, False, False, True))
print(formatter.format(formatter, formatter, formatter, formatter))
print(formatter.format(
"Bing",
"Bong",
"Bang",
"Bung"
))
Python错误:
[root@localhost python3.6]# python3.6 ex8.py
File "ex8.py", line 5
print(formatter.format(True, False, False, True))
^
SyntaxError: invalid syntax
答案 0 :(得分:1)
上一行缺少右括号:
print(formatter.format("one", "two", "three", "four"))
# This was missing ----------------------------------^