我想在我的python脚本中运行这个命令行文本到命令行。对如何做到这一点有什么建议吗?
explorer "ms-drive-to:?
destination.latitude=47.680504&destination.longitude=-122.328262&destination.name=Green Lake"
发布于 2020-03-17 06:28:22
如果您想在python shell中有效地运行它,如下所示:# it将打开windows map
>>> !explorer "ms-drive-to:?
destination.latitude=47.680504&destination.longitude=-122.328262&destination.name=Green Lake"
如果你想在代码中运行,就像其他人一样,method.All答案是正确的。
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.
注意使用双引号,单引号将无法正确识别!
windows uwp信息:https://docs.microsoft.com/en-us/windows/uwp/launch-resume/launch-maps-app
发布于 2020-03-16 20:30:28
当然,你可以像这篇文章中描述的那样做:
看起来你应该使用subprocess
https://stackoverflow.com/questions/60712781
复制相似问题