Python 使用webbrowser模块使用Google地图
我刚刚接触python,我想问一个简单的问题。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')
使用此代码有什么区别:
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
,第二个是使用默认浏览器input
,第二个代码sys.argv
自动是一个字符串列表,表示命令行上的参数(以空格分隔)。sys.argv[1:://code>获取脚本名称后的所有内容
一切。还是文件坏了?