首页
注册
登录
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
V2EX
›
Python
请问 from . import xxx 是什么用法,在何时使用?
zhuxiaoxi
·
zhuxiaoxi
·
2018 年 7 月 22 日
· 5901 次点击
这是一个创建于 2822 天前的主题,其中的信息可能已经有所发展或是发生改变。
import
用法
XXX
from
4 条回复
•
2018-07-23 07:02:05 +08:00
1
SimbaPeng
2018 年 7 月 22 日 via Android
1
py3 的相对导入,包内的模块导入处于同一顶级包下的模块、包、命名空间用的
2
frostming
2018 年 7 月 22 日
(.) 相对引用啊
假如当前 package 名是 foo,相当于
from foo import xxxx
3
wwqgtxx
2018 年 7 月 23 日
比如在系统库中就大量使用呀,引用同级目录下的文件
https://github.com/python/cpython/blob/master/Lib/asyncio/base_events.py#L37
https://github.com/python/cpython/blob/master/Lib/multiprocessing/forkserver.py#L11
4
rogwan
2018 年 7 月 23 日 via Android
相对路径优于绝对路径,否则换个地方就没法引用了
关于
·
帮助文档
·
自助推广系统
·
博客
·
API
·
FAQ
·
Solana
·
1143 人在线
最高记录 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 25ms ·
UTC 17:49
·
PVG 01:49
·
LAX 10:49
·
JFK 13:49
♥ Do have faith in what you're doing.
❯