I have this code:
import webbrowser
def main():
url = 'https://stackoverflow.com/users/7318120/d-l'
path_to_chrome = 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe' # fails
path_to_chrome = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s' # works
print(path_to_chrome)
webbrowser.get(path_to_chrome).open(url)
if __name__=='__main__':
''' This is executed when run from the command line '''
main()
I usually use \\
for windows
file paths and this has never failed before.
So my question is, why does the second path_to_chrome
which contains the %
part in the string variable work and not the first (which is actually the path to the executable)?