Skip to main content
 首页 » 编程设计

Python (3.3) 无效语法错误

2025年05月04日15soundcode

我正在尝试使用 python 创建一个程序,它可以帮助我们判断时间、日期和年份,但是我遇到了一些问题。

from datetime import datetime 
now = datetime.now() 
current_day = now.day 
print current_day 
current_month = now.month 
print current_month 
current_year = now.year 
print current_year 
input(press enter to exit) 

每次我运行它时,它都说无效语法,显然它与第三行有关。我不知道该怎么做!谁能帮帮我?

请您参考如下方法:

Python 3 不使用与 Python 2 相同的 print 语法。print 在 Python 3 中是一个函数,因此您需要 print(current_day)