- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在运行 pytzwhere 包提供的最简单的测试问题。模块导入,但我收到错误。 pytzwhere 似乎是从 GPS 坐标获取时区的一个不错的离线选项,但没有太多文档。任何有关如何协调这一点的帮助都将受到赞赏!
In [94]:
import tzwhere
w = tzwhere()
print w.tzNameAt(1.352083, 103.819836)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-94-0b50c8083e93> in <module>()
1 import tzwhere
2
----> 3 w = tzwhere()
4 print w.tzNameAt(1.352083, 103.819836)
TypeError: 'module' object is not callable
已根据下面的评论通过以下代码修改解决了此问题 -
In [108]:
from tzwhere import tzwhere
w = tzwhere.tzwhere()
print w.tzNameAt(1.352083, 103.819836)
-----------------------------------------------------------------------------
Reading json input file: /Users/user/anaconda/lib/python2.7/site-packages/tzwhere/tz_world_compact.json
Asia/Singapore
最佳答案
您不能像 w = tzwhere()
这样从模块中实例化 w。 tzwhere 是一个包含 tzwhere 类的模块。正如 Python 正确指出的那样,模块不可调用。
从 tzwhere 导入 tzwhere
w = tzwhere()
第一行从模块 tzwhere 导入class tzwhere。
编辑:如果您确实导入“我的方式”:-) w = tzwhere()
是 w 作为 class tzwhere 实例的有效创建。
通常在 Python 中,类将被命名为 TzWhere,这样可以避免这种混淆。
我假设您正在尝试使用 https://github.com/pegler/pytzwhere/blob/master/tzwhere/tzwhere.py
关于python - tzwhere (pytzwhere) - Python 2.7 和简单的测试用例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23769883/
我最近购买了《C 编程语言》并尝试了 Ex 1-8这是代码 #include #include #include /* * */ int main() { int nl,nt,nb;
早上好!我有一个变量“var”,可能为 0。我检查该变量是否为空,如果不是,我将该变量保存在 php session 中,然后调用另一个页面。在这个新页面中,我检查我创建的 session 是否为空,
我正在努力完成 Learn Python the Hard Way ex.25,但我无法理解某些事情。这是脚本: def break_words(stuff): """this functio
我是一名优秀的程序员,十分优秀!