[英]method_descriptor object has no attribute 'now' - while returning in function
while running the below snippet the error is thrown on datetime.time.now() Error msg: method_descriptor object has no attribute 'now'在运行以下代码段时,在 datetime.time.now() 上抛出错误错误消息:method_descriptor object has no attribute 'now'
from datetime import datetime
def samplefun(file_path, max_width=0, width=0, height=0):
file_dir = _get_file_dir(file_path)
file_name = _get_file_name(file_path)
return f"{file_dir}/thumbnails/{max_width}/pro_pic{datetime.time.now()}.jpg"
Remove the time
namespace:移除time
命名空间:
datetime.now()
EDIT:编辑:
If you need to remove certain parts of the timestamp, use replace
:如果您需要删除时间戳的某些部分,请使用replace
:
datetime.now().replace(microsecond=0)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.