标签:too argv 跳过 argument [1] 执行 div utf-8 nts
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
‘a test module‘
__author__=‘Vic‘
import sys
def test():
args=sys.argv
if len(args)==1:
print(‘Hello,world!‘)
elif len (args)==2:
pritn(‘Hello,%s!‘% args[1])
else:
print(‘Too many arguments!‘)
if __name__==‘__main__‘:
test()
使用import sys导入功能
__name__变量可以对当前引用该模块的函数进行判断,如果是主函数(main)则执行test功能,否则跳过
标签:too argv 跳过 argument [1] 执行 div utf-8 nts
原文地址:https://www.cnblogs.com/victorslave/p/10353949.html