当我尝试将非类型变量转换为字符串时,它不会改变吗?有没有更好的方法来存储日期?
When I try to convert nonetype variable to string it does not change? Is there any better way to store dates?
我正在制作一个程序来将日期存储在 Excel sheet 中以简化任务,然后我遇到了关于如何生成或如何存储日期的困惑轻松将它们写入 Excel sheet.
如果有人想尝试,我已经提供了下面的代码:
to_day = int(input("Enter the day today: "))
to_month = int(input("Enter the month: "))
to_year = int(input("Enter the year you are in: "))
today_date = print(to_day, "-", to_month, "-", to_year)
str_todaydate = str(today_date)
print(type(today_date))
print
returns None
,不是打印出来的字符串。改变这个:
today_date = print(to_day, "-", to_month, "-", to_year)
对此:
today_date = f"{to_day}-{to_month}-{to_year}"
print(today_date)
我正在制作一个程序来将日期存储在 Excel sheet 中以简化任务,然后我遇到了关于如何生成或如何存储日期的困惑轻松将它们写入 Excel sheet.
如果有人想尝试,我已经提供了下面的代码:
to_day = int(input("Enter the day today: "))
to_month = int(input("Enter the month: "))
to_year = int(input("Enter the year you are in: "))
today_date = print(to_day, "-", to_month, "-", to_year)
str_todaydate = str(today_date)
print(type(today_date))
print
returns None
,不是打印出来的字符串。改变这个:
today_date = print(to_day, "-", to_month, "-", to_year)
对此:
today_date = f"{to_day}-{to_month}-{to_year}"
print(today_date)