import:直接导入一个模块
from…import:是从一个模块中导入其中的函数
举例
suppport.py
def print_func(par):
print "Hello:",Par
return
使用from…import
使用模块中的函数,直接调用函数,不需要加模块名
from support import *
print_func("Runoob")
使用import
使用模块名.函数名
import support
support.print_func("Runoob")
摘录自Runoob.com
from……import同级目录导入方法
想在data_processing中调用d2ltorch
1、在d2l目录下新建空文件夹
__init__.py
2、在data_processing.py中
import sys
sys.path.append('/home/ras/cv/Good_py/dlnn_limu d2l') # 添加路径至项目名
from d2l import d2ltorch
然后就ok了