Search code examples
pythonpython-3.xwindowscommand-lineuwp-maps

How to run a url from inside a python script to command line?


I have this command line text that I want to run inside my python script to the command line. Any suggestions on how to do this?

explorer "ms-drive-to:? 



destination.latitude=47.680504&destination.longitude=-122.328262&destination.name=Green Lake"

Solution

  • If you want to effectively run this in python shell,like this: # it will open windows map

    >>> !explorer "ms-drive-to:? 
    destination.latitude=47.680504&destination.longitude=-122.328262&destination.name=Green Lake"
    

    If you want to run in code, do like others method.All the answers are correct.

    import os
    
    command_str = 'explorer "ms-drive-to:? destination.latitude=47.680504&destination.longitude=-122.328262&destination.name=Green Lake"'
    os.system(command_str)
    # it will open windows map, and driving directions to Green Lake from your current location.
    

    Be careful to use double quotes, single quotes will not be recognized correctly! results

    windows uwp info: https://learn.microsoft.com/en-us/windows/uwp/launch-resume/launch-maps-app