0

我收到一个我无法找出原因的缩进错误。
错误是

('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()
4

1 回答 1

1

您在源代码中混合了制表符和空格,Python 将制表符扩展到空格的算法导致缩进 8 个空格,而不是像循环SDV2 = xyList[0]中的其他行那样缩进 4 个空格。for

于 2014-10-28T17:55:58.873 回答