相关疑难解决方法(0)

2618
推荐指数
40
解决办法
308万
查看次数

如何将python日期时间转换为字符串,具有可读格式的日期?

t = e['updated_parsed']
dt = datetime.datetime(t[0],t[1],t[2],t[3],t[4],t[5],t[6]
print dt
>>>2010-01-28 08:39:49.000003
Run Code Online (Sandbox Code Playgroud)

如何将其转换为字符串?:

"January 28, 2010"
Run Code Online (Sandbox Code Playgroud)

python datetime string-formatting

163
推荐指数
6
解决办法
30万
查看次数

检查执行if语句的时间

我正在练习Python,我想编写一个程序来检查当前时间,看看它是否与下午2:12匹配并说:its lunch time所以首先我想出了使用import time模块,但我不知道如何?

我的问题是我不知道如何使用时间模块.或者我使用正确的语法?

我的代码:

import time

bake=time()
if bake == '2:12':
    print ('its time to eating lunch')
else :
   print ('its not the time for eating lunch')
Run Code Online (Sandbox Code Playgroud)

python

-1
推荐指数
1
解决办法
7362
查看次数

标签 统计

python ×3

datetime ×2

string-formatting ×1

time ×1