python - 我可以用 os.system 或 os.startfile 打开什么类型的文件?
问题描述
我可以用os.system
或打开什么类型的文件os.startfile
?我知道你可以使用:
paths,
file.txt,
file.py,
file.js,
file.css,
ETC..
但是如何打开 Chrome 和其他应用程序
解决方案
Python os.startfile 是一个非常有用的命令。您不仅可以打开文件,还可以打开应用程序。一种方法是单击应用程序并复制路径。然后将该路径放入 os.startfile() 中。请记住,它必须是 exe 或 lnk 文件。这是和示例:
os.startfile('Chrome.exe')
当您编写此代码时,python 将为您打开 Chrome。要在 chrome 中打开链接,您可以通过以下方式使用 webbrowser 模块:
webbrowser.open_new_tab('https://web.whatsapp.com/')
谢谢你!我希望这对你有用!
推荐阅读
- vue.js - 按下箭头按钮时如何隐藏vue-slick-carousel的边框?
- android - 可能的未处理承诺拒绝 (id:0):错误 - BLE
- spring - Mockito - 如何根据 HttpStatusCode 测试行为?
- mpi - 尽管从未发送过,但 MPI_Test 返回请求的真实标志?
- android - 使用 ExtractMpegFramesTest 在 Android 上提取视频帧并运行计算密集型函数而不是保存为图像
- azure-servicebus-topics - 在 Azure ServiceBus 主题中查看计划消息
- clang - 当我们需要在 Clang 前端 AST 中使用 EvaluatedExprVisitor 而不是 RecursiveASTVisitor
- linux - linux socket文件描述分配有多随机?
- c++ - C++17 PMR:: 在 unsynchronized_pool_resource 中设置块数及其大小
- delphi - 如何使圆形德尔福表格从角落完美圆润也适用于 Win10