首页
注册
登录
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-07-22 21:45:20 +08:00
· 5733 次点击
这是一个创建于 2614 天前的主题,其中的信息可能已经有所发展或是发生改变。
import
用法
XXX
from
4 条回复
•
2018-07-23 07:02:05 +08:00
1
SimbaPeng
2018-07-22 22:18:02 +08:00 via Android
1
py3 的相对导入,包内的模块导入处于同一顶级包下的模块、包、命名空间用的
2
frostming
2018-07-22 22:18:34 +08:00
(.) 相对引用啊
假如当前 package 名是 foo,相当于
from foo import xxxx
3
wwqgtxx
2018-07-23 00:16:10 +08:00
比如在系统库中就大量使用呀,引用同级目录下的文件
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-07-23 07:02:05 +08:00 via Android
相对路径优于绝对路径,否则换个地方就没法引用了
关于
·
帮助文档
·
自助推广系统
·
博客
·
API
·
FAQ
·
实用小工具
·
936 人在线
最高记录 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 23ms ·
UTC 21:59
·
PVG 05:59
·
LAX 14:59
·
JFK 17:59
Developed with
CodeLauncher
♥ Do have faith in what you're doing.
❯