【发布时间】:2017-10-23 20:11:44
【问题描述】:
我需要将月份从字符串值更改为整数值,以便进行计算。我正在使用可以提供当前日期的日期时间库,我需要将其与用户输入的日期进行比较,以找到整数形式的月份之间的差异。
import datetime
current_month = datetime.date.today().strftime('%B')
month_join = input('Please enter the month you joined')
month_difference = current_month - month_join
如果可能,我希望输入为一个月。如果没有,我将使用:
month_join = int(input('Please enter the month you joined')
【问题讨论】:
标签: python string datetime integer