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

请问一个相对导入的问题

  •  
  •   saximi · Aug 4, 2017 · 2271 views
    This topic created in 3213 days ago, the information mentioned may be changed or developed.
    from . import spam
    关于上面这个相对导入语句,在 PYTHON3 中,如果在主程序所在目录找不到 spam.py 文件,会不会在 sys.path 中搜索这个文件呢 ?
    3 replies    2017-08-05 17:55:45 +08:00
    jingniao
        1
    jingniao  
       Aug 4, 2017 via Android
    路过
    虽然做 Python 的,但很少用相对路径,这种也不是很清楚
    不过,自己试验下很难?
    CryMeatel
        2
    CryMeatel  
       Aug 4, 2017
    . 在 python3 中只能用在模块中,不能用在程序入口
    zhusimaji
        3
    zhusimaji  
       Aug 5, 2017
    相对导入只能用在模块当中,无论 python 版本,至少目前是这样
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3068 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 02:37 · PVG 10:37 · LAX 19:37 · JFK 22:37
    ♥ Do have faith in what you're doing.