Python 我想使用datetime module utcfromtimestamp方法,但它在NinjaIDE中不起作用
我想使用Python 我想使用datetime module utcfromtimestamp方法,但它在NinjaIDE中不起作用,python,python-3.x,datetime,python-import,Python,Python 3.x,Datetime,Python Import,我想使用datetimemoduleutcfromtimestamp方法,但它在忍者IDE中不起作用。我怎样才能解决我的问题 我的代码: #-*- coding: utf-8 -*- import datetime print (datetime.datetime.utcfromtimestamp(130130301)) Ninja IDE 2.3会写入以下错误消息: File "C:\Users\test\Desktop\datetime.py", line 3, in <module
datetime
moduleutcfromtimestamp
方法,但它在忍者IDE中不起作用。我怎样才能解决我的问题
我的代码:
#-*- coding: utf-8 -*-
import datetime
print (datetime.datetime.utcfromtimestamp(130130301))
Ninja IDE 2.3会写入以下错误消息:
File "C:\Users\test\Desktop\datetime.py", line 3, in <module>
print (datetime.datetime.utcfromtimestamp(130130301))
AttributeError: 'module' object has no attribute 'utcfromtimestamp'
文件“C:\Users\test\Desktop\datetime.py”,第3行,在
打印(datetime.datetime.utcfromtimestamp(130301))
AttributeError:“模块”对象没有属性“utcfromtimestamp”
我安装了Python 3.4并在首选项中设置了路径。您将文件命名为
datetime.py
,Python将其导入到标准库datetime
:
File "C:\Users\test\Desktop\datetime.py", line 3, in <module>
# ^^^^^^^^
文件“C:\Users\test\Desktop\datetime.py”,第3行,在
# ^^^^^^^^
因此,第一个datetime
是您的模块,第二个datetime
是模块中引用自身的全局,而您的模块本身没有utcfromtimestamp
全局
将文件重命名为其他文件。您将文件命名为
datetime.py
,Python将其导入,而不是标准库datetime
:
File "C:\Users\test\Desktop\datetime.py", line 3, in <module>
# ^^^^^^^^
文件“C:\Users\test\Desktop\datetime.py”,第3行,在
# ^^^^^^^^
因此,第一个datetime
是您的模块,第二个datetime
是模块中引用自身的全局,而您的模块本身没有utcfromtimestamp
全局
将文件重命名为其他文件。read read