Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用webbrowser模块使用Google地图_Python_Module_Sys_Pyperclip - Fatal编程技术网

Python 使用webbrowser模块使用Google地图

Python 使用webbrowser模块使用Google地图,python,module,sys,pyperclip,Python,Module,Sys,Pyperclip,我刚刚接触python,我想问一个简单的问题。 使用此代码有什么区别: 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')

我刚刚接触python,我想问一个简单的问题。
使用此代码有什么区别:

    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)
区别在于:

  • 对于第一个,使用目标浏览器是
    chrome.exe
    ,第二个是使用默认浏览器
  • 第一个代码使用内置函数import
    input
    ,第二个代码
    sys.argv
    自动是一个字符串列表,表示命令行上的参数(以空格分隔)。
    sys.argv[1:://code>获取脚本名称后的所有内容

  • 一切。还是文件坏了?