【发布时间】:2022-01-08 06:21:36
【问题描述】:
我在一个目录中有许多 .txt 文件。起初我想在屏幕上一个一个地绘制文件,如果看起来不错,那么我想将 .txt 文件复制到一个名为“test_folder”的目录中。 如果它看起来不正常,那么我不想将 .txt 文件复制到“test_folder”目录。
我尝试了下面的脚本,但是我不能这样做,因为我是 python 新手。我希望专家可以帮助我克服这个问题。在此先感谢。
import numpy as np
import os,glob,shutil
import matplotlib.pyplot as plt
os.mkdir('test_folder')
for filex in glob.glob("*.txt"):
print(filex)
data=np.loadtxt(filex)
plt.plot(data)
plt.show()
if plot_looks_nice == "yes":
#copy the filex to the directory "test_folder"
shutil.copy(filex,'test_folder')
elif plot_looks_nice == "no":
#donot copy the filex to the directory "test_folder"
print("not copying files as no option chosen")
else:
print("Please enter yes or no.")
【问题讨论】:
标签: python numpy for-loop matplotlib operating-system