-
Notifications
You must be signed in to change notification settings - Fork 0
/
Exe_05.py
28 lines (26 loc) · 845 Bytes
/
Exe_05.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import sys, getopt
print('Number of args:', len(sys.argv), 'arguments.')
print('Argument list :', str(sys.argv))
print()
#input("\n\nPress Enter to exit.")
# [Getopt] tuts
def main(argv):
inputfile = ''
outputfile = ''
try:
opts, args = getopt.getopt(argv, "hi:o", ["ifile=", "ofile="])
except getopt.GetoptError:
print('Exe_05.py -i <inputfile> -o <outputfile>')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('Exe_05.py -i <inputfile> -o <outputfile>')
sys.exit()
elif opt in ("-i", "--ifile"):
inputfile = arg
elif opt in ("-o", "--ofile"):
outputfile = arg
print(' Input file is "', inputfile, '"')
print('Output file is "', outputfile, '"')
if __name__ == "__main__":
main(sys.argv[1:])