擅长:python、mysql、java
<p>我假设您想将日期('2011年1月1日','2011年12月31日')和('2011年1月1日','2011年12月31日')转换为时间元组</p>
<pre><code> from datetime import datetime
date_str = "Jan 1, 2011"
fmt = "%b %d, %Y"
# Construct a datetime object
date_obj = datetime.strptime(date_str, fmt)
# Convert it to any string format you want
new_fmt = "%Y, %m, %d"
print date_obj.strftime(new_fmt)
# Prints'2011, 01, 01'
# If you want python timetuple then
t_tuple = date_obj.timetuple()
</code></pre>