如何在python中声明多个arraylist?

时间:2015-11-02 14:18:47

标签: arrays python-2.7 declaration

抱歉,我想以自动方式:

  • 读取多个文件
  • 创建一个多数组
  • 影响数组中的数据,

由于

#read files :
donnees_T_surf_1=open("simulation/1/GR_TG1.TXT",'r')
donnees_T_surf_2=open("simulation/2/GR_TG1.TXT",'r')
donnees_T_surf_500=open("simulation/500/GR_TG1.TXT",'r')

# declaration of array
T_surf_test_1, T_surf_test_2, T_surf_test_3, T_surf_test_4,
T_surf_test_5, T_surf_test_500=[], [], [], [], [], []
#affectation in array
for line in donnees_T_surf_1:
    donnees = line.strip().split()
    T_surf_1.append(float(donnees[0]))

for line in donnees_T_surf_2:
    donnees = line.strip().split()
    T_surf_2.append(float(donnees[0]))

for line in donnees_T_surf_500:
    donnees = line.strip().split()
    T_surf_500.append(float(donnees[0]))

我想要这个结果:

#read files :
for j in range(500) :
    donnees_T_surf.append(open(str(j)+"GR_TG1.TXT",'r')) 
# declaration of array
    for i in range(500) :
        T_surf_test_str(i) =[]
#affectation in array
for count in range(500) :
    for line in donnees_T_surf_str(i):
        donnees = line.strip().split()
        T_surf_str(i).append(float(donnees[0]))

当我运行它时,我获得:

T_surf_test_str(i) =[]        
SyntaxError: can't assign to function call

0 个答案:

没有答案