2016-10-01 33 views
-1

我只是新的python,我想問一個簡單的問題。
什麼是使用這個代碼之間的區別:使用webbrowser模塊使用谷歌地圖

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() 

和驗證碼:

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) 
+0

一切。或者文檔被破壞了? –

回答

0

有多種不同的是:

  1. 有了第一個,使用目標瀏覽器chrome.exe和其次是使用默認瀏覽器。
  2. 使用從內置函數input導入的第一個代碼和第二個代碼sys.argv自動是一個表示命令行參數(用空格分隔)的字符串列表。 sys.argv[1:]獲得腳本名稱後的所有內容。