您应该使用
strptime:此函数根据格式解析表示时间的字符串。返回值为struct_time。
该参数的默认值格式
%a %b %d %H:%M:%S%Y相匹配的格式的ctime由()返回。
因此,在您的情况下,请尝试以下行,因为默认格式是ctime中的格式:
import datetimeimport timedatetime.datetime.strptime(time.ctime(), "%a %b %d %H:%M:%S %Y")
返回值:
datetime.datetime(2012, 4, 21, 4, 22, 00)



