14.2.3 长格式选项
对于一个有两个选项的程序(–noarg和–witharg),长参数序列应为[‘noarg’,‘witharg=’]。
import getopt
opts,args = getopt.getopt(
['--noarg',
'--witharg','val',
'--witharg2=another'],
'',
['noarg','witharg=','witharg2='],
)
for opt in opts:
print(opt)
由于这个示例程序没有任何短格式选项,所以getopt()的第二个参数是一个空串。