-1

i'm just new to python and i want to ask a simple question.
what's the difference between using this code:

    import webbrowser, pyperclip, sys        

    chrome = "C:/Program Files/Google/Chrome/Application/chrome.exe %s"

    def location_finder():
        output = input('Type the place you want to find!\n')

        webbrowser.get(chrome).open('https://www.google.com/maps/place/' + output)

    location_finder()

and this code:

    import webbrowser, pyperclip, sys  

    if len(sys.argv) > 1:
        address = ' '.join(sys.argv[1:])
    else:
        address = pyperclip.paste()  

    webbrowser.open('https://www.google.com/maps/place/' + address)
Lucifer1002
  • 59
  • 1
  • 1
  • 5

1 Answers1

0

The diffrent is:

  1. With the first one, using target browser is chrome.exe and the second is using the default browser.
  2. The first code using import from built in function input and the second code sys.argvis automatically a list of strings representing the arguments (as separated by spaces) on the command-line. The sys.argv[1:] get everything after the script name.
AlphaWolf
  • 395
  • 2
  • 7
  • 16