from __future__ import absolute_import的作用

pkg/

pkg/striing.py

pkg/main.py

假如你在main.py中想要引用string.py则应写入import string

but 这种写法引用的是pkg/string.py这个string即引用的是相同目录下的string

如果:我要引用的是Python系统自带的标准的string,那么我的这个引用则是错误的,因为路径为相对引用,引用的是pkg/string

解决方法:正确的打开方式是加入这句话:from __future__ import absolute_import

https://www.cnblogs.com/laowangxieboke/p/10307381.html

用一个例子来演示会更加清晰
原文地址:https://www.cnblogs.com/hixiaowei/p/14309718.html