python学习笔记01--环境变量

1、比如linux下将/tmp路径加入环境变量

[root@localhost ~]# cat .bashrc 
export PYTHONPATH=$PYTHONPATH:/tmp     增加环境变量

2、查看刚增加的环境变量:

>>> import sys,pprint

>>> pprint.pprint(sys.path)
['',
 '/root',
 '/tmp',
 '/usr/lib64/python27.zip',
 '/usr/lib64/python2.7',


3、windows下只需编辑环境变量参数增加PYTHONPATH   

4、模块自带函数

>>> import copy

>>> dir(copy)               dir可以模块所有的函数、变量等

['Error', 'PyStringMap', '_EmptyClass', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_copy_dispatch', '_copy_immutable', '_copy_inst', '_copy_with_constructor', '_copy_with_copy_method', '_deepcopy_atomic', '_deepcopy_dict', '_deepcopy_dispatch', '_deepcopy_inst', '_deepcopy_list', '_deepcopy_method', 


扫描二维码关注公众号,回复: 4932091 查看本文章

在使用from copy import * 时可以使用__all__里的函数

>> copy.__all__          

['Error', 'copy', 'deepcopy']

__file__可以查看模块路径:

>>> print copy.__file__                  
/usr/lib64/python2.7/copy.pyc


猜你喜欢

转载自blog.csdn.net/maibm/article/details/80276968
今日推荐