python-3.x - 找不到程序时关闭 cmd 的批处理文件
问题描述
我正在编写一个 python 程序,它从用户那里获取输入,然后创建一个批处理文件并打开该程序,我希望如果找不到程序,那么它将该错误返回给 python 并关闭弹出窗口
Windows cannot find 'room'. make sure you type correctly, and then try again.
和命令。
我不知道如何解决这个问题。
def batch(text):
bat_file = open("hello.bat","w")
bat_file.write("start "+text)
bat_file.close()
os.startfile("hello.bat")
正如我上面提到的,我想关闭弹出窗口和 cmd。
解决方案
推荐阅读
- c# - C# 数据网格视图到数据网格视图
- unit-testing - 如何测试 bin 文件夹中的主要方法(Dart 独立命令行应用程序)
- apache-spark - 无法通过并行 JDBC 连接读取数据库表:Databricks 上的 Spark
- r - 达到阈值时 dplyr 重置计数器
- c# - WinZip 版本文件的 SharpZipLib 问题
- javascript - 如何在节点 js 中使用基本身份验证在节点获取模块中传递数据
- c++ - 在内部使用 dll 中的 C++ 标准库
- html - 难以将单列 CSS 菜单转换为多个 3 列一
- oracle - 禁用oracle中的行更新
- javascript - 承诺在 ipad 上的 Safari 上解决不一致