我收到缩进错误,我无法弄清楚原因 错误是
('unexpected indent', ('C:/Hamid/Failure_index.py',15,1,'\tSDV2=xyList[0]\n')).
我的代码是
from abaqusConstants import *
from odbAccess import *
from visualization import *
#---------------------------------------------------------------------------
out_file= 'C:\Hamid\Stochastic\Python_script_for_Monte_Carlo_simulation\Microtensile/Failure_index.dat'
fid = open(out_file,'w')
for i in range(1,50):
odb_path = 'C:\Hamid\Stochastic\Python_script_for_Monte_Carlo_simulation\Microtensile/Microtens-'+str(i)+'_xs.odb'
session.openOdb(name=odb_path)
odb = session.odbs[odb_path]
session.viewports['Viewport: 1'].setValues(displayedObject=odb)
xyList = session.xyDataListFromField(odb=odb, outputPosition=INTEGRATION_POINT, variable=(('SDV2', INTEGRATION_POINT), ), elementSets=(' ALL ELEMENTS', ))
SDV2 = xyList[0]
fid.write(SDV2+'\n')
odb.close()
fid.close()
答案 0 :(得分:1)
您在源代码中混合了制表符和空格,而用于将制表符扩展到空格的Python算法会导致SDV2 = xyList[0]
缩进8个空格,而不是像{{1}中的其他行一样缩进4个空格}循环。