推荐学习书目
› 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
zhuxiaoxi
V2EX  ›  Python

请问 from . import xxx 是什么用法,在何时使用?

  •  
  •   zhuxiaoxi ·
    zhuxiaoxi · Jul 22, 2018 · 6174 views
    This topic created in 3012 days ago, the information mentioned may be changed or developed.
    4 replies  •  2018-07-23 07:02:05 +08:00
    SimbaPeng
        1
    SimbaPeng  
       Jul 22, 2018 via Android   ❤️ 1
    py3 的相对导入,包内的模块导入处于同一顶级包下的模块、包、命名空间用的
    frostming
        2
    frostming  
       Jul 22, 2018
    (.) 相对引用啊

    假如当前 package 名是 foo,相当于
    from foo import xxxx
    rogwan
        4
    rogwan  
       Jul 23, 2018 via Android
    相对路径优于绝对路径,否则换个地方就没法引用了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1009 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 22:12 · PVG 06:12 · LAX 15:12 · JFK 18:12
    ♥ Do have faith in what you're doing.