【发布时间】:2020-11-16 13:10:07
【问题描述】:
我编写了一个在 Jupyter Notebook 上运行的函数。现在我想在 Python 2.7.18 中运行相同的代码,但在“”部分出现语法错误..
import datetime
now = datetime.datetime.now()
i = now.year
j = now.month
k = now.day
def concat(i, j):
return eval(f"{i}{j}{k}")
【问题讨论】:
-
您为什么要使用 Python 2? Python 2 已于今年结束。
-
为什么要在 python 2.7 中运行新的东西?
-
在 Py3.6 之前不支持 f 字符串。
-
原因与问题无关。我没有问原因
-
那么请注意,Python 2 和 Python 3 之间还有很多其他变化,例如
print、input和range的行为。你必须解决这些问题。
标签: python pandas python-2.7