将opt文件转为txt文件,用于训练

import numpy as np
import operator
import os
import copy
from matplotlib.font_manager import FontProperties
from scipy.interpolate import lagrange
import random
import matplotlib.pyplot as plt
# 把opt文件内的逗号变为空格
#数据在我的百度云数据库txt文件,及opt文件
np.set_printoptions(threshold=np.inf) #输出全部矩阵不带省略号
random.seed(10)
with open('opt/Vit_3Day.opt','r') as f:
    file = f.read()
    file = file.strip().split('\n')
    for data in file:
        data = data.replace(',',' ')#replace不能用于列表
#         data = data.replace('-1','0')
        with open('txt/final37.txt','a') as f:
            f.write(data+'\n')

 

你可能感兴趣的:(Python)