【发布时间】:2021-03-22 06:02:17
【问题描述】:
我正在用 Python 创建一个需要在 Unix 和 Windows 中运行的 GUI。在 python 主脚本中,我需要创建并打开(如弹出窗口)一个文本文件。我有 unix 操作系统的代码,它是:
os.chdir(path=app.sourceFolder+"/Fastq_downloaded")
files = os.listdir(os.getcwd())
sample_data = open("sample_data.txt", "w")
sample_data.write("ID" + "\t" + "Condition" + "\n")
for i in range(len(files)-1):
sample_data.write(files[i][:-6] + "\t" + "\n")
sample_data.write(files[-1][:-6] + "\t")
sample_data.close()
if "Linux" in o_sys or "Darwin" in o_sys:
os.system('gedit sample_data.txt')
首先我创建一个包含信息的文件,然后从终端调用 gedit 打开它。但在 Windows 中,我不知道如何从终端打开文本文件并将其显示给用户。一些建议?非常感谢
【问题讨论】:
-
notepad sample_data.txt?
标签: python windows cmd terminal text-editor