请将这两个程序写在一起if __name__ == '__main__': app = QApplication(sys.argv) window = MyWindow() sys.stdout = window # 将标准输出重定向到 print 输出信息框中 print("print 成功") window.show() sys.exit(app.exec_()) if __name__ == '__main__': while (1): cols = ['0', '1', '2', '3', '4', '5', '6', '7'] line_names = ['VitalSigns1', 'VitalSigns2', 'VitalSigns3', 'VitalSign4', 'VitalSign5', 'VitalSign6', 'VitalSign7', 'VitalSigns8'] nowfile = time.strftime('%Y-%m-%d-%H-%M-%S', time.localtime()) if excel_name != None and over != 0: df1 = pd.read_excel(excel_name, sheet_name='Sheet1') plt.plot(df1[cols[0]], label=line_names[0]) plt.plot(df1[cols[1]], label=line_names[1]) plt.plot(df1[cols[2]], label=line_names[2]) plt.plot(df1[cols[3]], label=line_names[3]) plt.plot(df1[cols[4]], label=line_names[4]) plt.plot(df1[cols[5]], label=line_names[5]) plt.plot(df1[cols[6]], label=line_names[6]) plt.plot(df1[cols[7]], label=line_names[7]) plt.legend() plt.xlabel('NUM DATA') plt.ylabel('LIFE DATA') plt.title('Title of the plot') plt.savefig(nowfile, dpi=300) plt.show() over = 0 main()
时间: 2024-01-24 08:04:24 浏览: 60
请注意代码缩进和格式,将两个程序整合成一个:
```
if __name__ == '__main__':
app = QApplication(sys.argv)
window = MyWindow()
sys.stdout = window # 将标准输出重定向到 print 输出信息框中
print("print 成功")
window.show()
sys.exit(app.exec_())
while (1):
cols = ['0', '1', '2', '3', '4', '5', '6', '7']
line_names = ['VitalSigns1', 'VitalSigns2', 'VitalSigns3', 'VitalSign4', 'VitalSign5', 'VitalSign6',
'VitalSign7', 'VitalSigns8']
nowfile = time.strftime('%Y-%m-%d-%H-%M-%S', time.localtime())
if excel_name != None and over != 0:
df1 = pd.read_excel(excel_name, sheet_name='Sheet1')
plt.plot(df1[cols[0]], label=line_names[0])
plt.plot(df1[cols[1]], label=line_names[1])
plt.plot(df1[cols[2]], label=line_names[2])
plt.plot(df1[cols[3]], label=line_names[3])
plt.plot(df1[cols[4]], label=line_names[4])
plt.plot(df1[cols[5]], label=line_names[5])
plt.plot(df1[cols[6]], label=line_names[6])
plt.plot(df1[cols[7]], label=line_names[7])
plt.legend()
plt.xlabel('NUM DATA')
plt.ylabel('LIFE DATA')
plt.title('Title of the plot')
plt.savefig(nowfile, dpi=300)
plt.show()
over = 0
main()
```
阅读全文