python import的模块都是库里面的,而自己的模块也可以添加
比如python的json处理,库里没有json文件,import json不行。
网上大部分人告诉你处理json用 dumps和loads这两个函数,而你发现import 的json文件没有这两个函数功能,那么请使用如下方法:
try:
import json
except ImportError:
sys.path.append('./py-lib/simplejson')#这句要是不懂 我也帮不了你。自己去查。
import simplejson as json
通过sys.path.append('./my_module') 可以将自己的模块添加进python的库,作为内部库文件使用,直接import。