V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
302790951
V2EX  ›  Python

怎么动态调用第三方库?

  •  
  •   302790951 · 2014-11-25 19:20:10 +08:00 · 2378 次点击
    这是一个创建于 3457 天前的主题,其中的信息可能已经有所发展或是发生改变。
    from lib.aa.bb import cc

    其中aa bb是动态的,貌似不能用变量存储 还有什么办法动态调用第三方库吗?
    5 条回复    2014-11-25 21:20:08 +08:00
    11
        1
    11  
       2014-11-25 19:25:26 +08:00   ❤️ 1
    302790951
        2
    302790951  
    OP
       2014-11-25 20:35:46 +08:00
    @11 感谢

    还有一个问题,python二级目录下的类怎么引用?

    from test.lib.test import test
    报错
    ImportError: No module named lib.test
    c
        3
    c  
       2014-11-25 20:37:31 +08:00
    302790951
        4
    302790951  
    OP
       2014-11-25 21:19:43 +08:00
    @11 用imp 库解决了 感谢
    302790951
        5
    302790951  
    OP
       2014-11-25 21:20:08 +08:00
    @c 用imp 库解决了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3228 人在线   最高记录 6547   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 13:12 · PVG 21:12 · LAX 06:12 · JFK 09:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.