GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.cnblogs.com — python中import和from-import的区别 - AnimalRabbit - 博客园 python中import和from-import的区别. import导入模块的路径两种方式
# 将模块所在路径再程序中添加到sys.path列表中 import sys sys.path import导入模块按照sys.path顺序依次查找,“”代表当前路径 # 修改操作系统的PYTHON_PATH环境变量 # 系统的环境变量 export PYTHON_PATH=$PYTHON_PATH:新的路径 . import 模块名 和 from 模块名 import * 是不同的; 1. 调用模块属性的区别 # . 类中的私有属性 # 本质做了一个名字重整 class test() self.__name __name 名字重整成 _test__name _littlethree : 模块的私有属性(数据) from 模块 import * : 导入模块时,会跳过私有属性; import 模块 : 通过引用可以访问私有属性
. 重新导入模块的方法 import a import a # 注意:import多次,只有第一次会执行; # 或者重启程序 """reload()方法能重新导入模块""" from imp import reload reload(模块名)
import和from-import的显著区别
公告 |
| You are visitor 01402809 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |