【发布时间】:2014-07-15 05:35:06
【问题描述】:
from datetime import datetime
now = datetime.now()
user_input = input("Would you like to know the date and time today?").upper()
if user_input == "YES":
print "The date and time is: " + "%s/%s/%s - %s:%s:%s" % (now.day, now.month, now.year, now.hour, now.minute, now.second)
我正在尝试让 user_input 全部变为大写,因此我不必包含以下代码:
if user_input == "yes" or "YES" or "YeS" ... etc.
非常感谢任何帮助!
【问题讨论】:
-
你的问题陈述是什么?在
input声明之后user_input的值是多少? -
您想知道今天的日期和时间吗?是 回溯(最近一次通话最后一次):文件“Time_and_Date.py”,第 4 行,在
user_input = input("Would you like知道今天的日期和时间吗?").upper() 文件“ ”,第 1 行,在 NameError: name 'yes' is not defined\ 当我输入 yes 作为输入时会发生什么。 ..
标签: python datetime python-3.x