Skip to content

Commit e9a1137

Browse files
author
tuntun
committed
Python3命令行
1 parent c00073b commit e9a1137

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sys_argv.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def process_command_line(argv):
2525
'-h', '--help', action='help',
2626
help='Show this help message and exit.')
2727
parser.add_option(
28-
'-u', '--url', action='store',
28+
'-u', '--url', action='store', dest = 'link',
2929
help='Open a link.')
3030
settings, args = parser.parse_args(argv)
3131
# check number of arguments, verify values, etc.:
@@ -37,13 +37,14 @@ def process_command_line(argv):
3737

3838
def main(argv=None):
3939
settings, args = process_command_line(argv)
40+
print(settings)
4041
# application code here, like:
4142
run(settings, args)
4243
return 0 # success
4344

4445
def run(settings, args):
45-
if settings.url:
46-
webbrowser.open(settings.url, 1)
46+
if settings.link:
47+
webbrowser.open(settings.link, 1)
4748

4849

4950
if __name__ == '__main__':

0 commit comments

Comments
 (0)