TypeError: data; found string, expecting tuple in Abaqus by Python Script

TypeError: data; found string, expecting tuple in Abaqus by Python Script

我想将文本文件中提取的数据读入Abaqus文件中进行仿真。 这是我的代码:

import os                 
os.chdir(r"dir")       
for file in os.listdir("dir"):
    if file.endswith('.txt'):    
          print os.path.join(r"dir", file)     
          with open(file) as f:     
              lines = f.readlines()  
              for line in lines[:-1]:  
                  first, second = tuple(map(float, line.split()))  
                  print '(%g, %g),' % (first, second),  
              first, second = tuple(map(float, lines[-1].split()))  
              pp =  '(%g, %g)' % (first, second)  
              print pp  

mdb.models['Model-1'].TabularAmplitude(data=(pp), name='NewAmplitude', smooth=
SOLVER_DEFAULT, timeSpan=STEP)

出现的错误是:

"TypeError: data; found string, expecting tuple"

谁能帮忙解决这个问题?

这段代码应该可以解决问题:

import os                 
os.chdir(r"dir")

pp = []
for file in os.listdir("dir"):
    if file.endswith('.txt'):    
        print os.path.join(r"dir", file)     
        with open(file) as f:     
            for line in f:  
                pp.append(map(float, line.split()))
print pp.__repr__()[1:-1]

mdb.models['Model-1'].TabularAmplitude(data=pp, 
                                       name='NewAmplitude', 
                                       smooth=SOLVER_DEFAULT, 
                                       timeSpan=STEP)