我正在从ZedA.Shaw的“艰难的学习Python”中学习Python,这本书强烈推荐Python 2而不是Python 3。然而,到目前为止,我一直在使用Python 3(以便了解这两个版本之间的区别)。练习8中的下列代码,
formatter = "%r %r %r %r"
...
print(formatter % (
"I had this thing.",
"That you could type up right.",
"But it didn't sing.",
"So I said goodnight."
)
)PowerShell在Python2中工作,但在Python3中不起作用,在Python 3中,print语句的第一行出现了语法错误。
我说得对吗?Python2和Python3之间的大部分区别与print语句有关吗?在Python 3中,上面的代码会是什么样子?
发布于 2017-07-21 00:12:40
该问题是由前面的print语句中的未关闭括号引起的。
https://stackoverflow.com/questions/45179964
复制相似问题