2017-10-08 68 views

回答

0

你原来的问题还不太清楚......我提议重写它,但我不确定我是否理解了这个问题。同时很难使用eval()命令,因为我没有理解输入文件的格式。我宁愿考虑:

import numpy as np 
filenames = ["toto.dat","tata.dat","tutu.dat","titi.dat","tyty.dat"] 
for count,file in enumerate(filenames): 
    with open(file,"r") as f: 
     inp = np.array(f.readlines()) 
    if count==1: 
     xc = inp 
    elif count==2: 
     yc = inp 
    elif count==3: 
     x1 = inp 
    elif count==4: 
     y1 = inp 
    else: 
     x2 = inp 
+0

嗨,感谢您的答案,但是当我尝试像你的代码中导入numpy时,显然它不能找到numpy作为模块。所以它只是在文件的第一行出现错误。 – MattyS11

+0

安装numpy。如果您使用的是anaconda ==> conda install numpy。否则用点:pip安装numpy(待验证,我从不使用pip)。否则任何安装程序 –