我有一个脚本需要在脚本中的不同行执行以下操作:
today_date = datetime.date.today()
date_time = datetime.strp(date_time_string, '%Y-%m-%d %H:%M')
Run Code Online (Sandbox Code Playgroud)
在我的import语句中,我有以下内容:
from datetime import datetime
import datetime
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
AttributeError: 'module' object has no attribute 'strp'
Run Code Online (Sandbox Code Playgroud)
如果我将import语句的顺序更改为:
import datetime
from datetime import datetime
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
AttributeError: 'method_descriptor' object has no attribute 'today'
Run Code Online (Sandbox Code Playgroud)
如果我再次将import语句更改为:
import datetime
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
AttributeError: 'module' object has no attribute 'strp'
Run Code Online (Sandbox Code Playgroud)
这里发生了什么,如何让两者兼顾?欣赏它.谢谢.