我想使用datetime modul utcfromtimestamp方法,但它不能在Ninja-IDE中工作 [英] I want to use datetime modul utcfromtimestamp method but its not work in Ninja-IDE

查看:1258
本文介绍了我想使用datetime modul utcfromtimestamp方法,但它不能在Ninja-IDE中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 datetime module utcfromtimestamp 方法,但它在Ninja-IDE中不起作用。我如何解决我的问题?

I want to use datetime module utcfromtimestamp method but its not work in Ninja-IDE. How I can solve my problem?

我的代码:

#-*- coding: utf-8 -*-
import datetime
print (datetime.datetime.utcfromtimestamp(130130301))

Ninja-IDE 2.3写入此错误消息:

And Ninja-IDE 2.3 writes this error message:

File "C:\Users\test\Desktop\datetime.py", line 3, in <module>
    print (datetime.datetime.utcfromtimestamp(130130301))
AttributeError: 'module' object has no attribute 'utcfromtimestamp'

我安装了Python 3.4,并在首选项中设置了路径。

I installed Python 3.4 and setup the path in preferences.

推荐答案

datetime.py ,Python导入,而不是标准库 datetime

You named your file datetime.py, and Python imported that instead of the standard library datetime:

File "C:\Users\test\Desktop\datetime.py", line 3, in <module>
#                           ^^^^^^^^

所以第一个 datetime 是您的模块,第二个 datetime 是您的模块中引用自身的全局,而您的模块本身不具有 utcfromtimestamp global。

So the first datetime is your module, the second datetime a global in your module that references itself, and your module doesn't itself have a utcfromtimestamp global.

将您的文件重命名为其他内容。

Rename your file to something else.

这篇关于我想使用datetime modul utcfromtimestamp方法,但它不能在Ninja-IDE中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆