Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 pylibnet 库中自我介绍,我想问你如何获取在这段代码中导入的常量。
import libnet from libnet.constants import *
我尝试 help(libnet) 但我的问题没有任何答案。
谢谢!!
你试过dir(libnet.constants)吗?
dir(libnet.constants)
也libnet.constants.__dict__应该工作。
libnet.constants.__dict__
为了减少噪音,你可以做
[x for x in libnet.constants.__dict__ if x[:2] != '__' and not callable(libnet.constants.__dict__[x])]