#!/usr/bin/env python3
# -*- coding: utf-8 -*-
‘a test module‘
__author__ = ‘ruixi‘
import sys
def test():
args = sys.argv
if len(args) == 1:
print(‘Hello world!‘)
elif len(args) == 2:
print(‘Hello, %s‘ % args[1])
else:
print(‘Too many argument‘)
if __name__ == ‘__main__‘:
test()
_
前缀来实现的。__xxx__
这样的变量是特殊变量,可以直接被引用,但是有特殊用途,比如上面的__author__
、__name__
_xxx
和__xxx
这样的函数或变量就是非公开的(private),不应该被直接引用。pip install Pillow
Anaconda
,可以将很多模块一次安装好。sys
模块的path
变量中,如果要添加自己的搜索目录,1、直接修改sys.path
,添加要搜索的目录,这种方法在运行时修改,运行后失效;2、设置环境变量PYTHONPATH
,该环境变量的内容会自动添加到模块搜索路径中。import sys
sys.path.append(‘/User/michael/my_py_scripts‘)
原文:https://www.cnblogs.com/tsruixi/p/12584026.html