值错误:需要解压缩超过0的值

时间:2017-05-15 05:50:38

标签: python

我尝试运行以下Python脚本,并收到以下错误。有人可以帮忙吗?感谢。

sP=['','','']
vP=['','','']
for rows in range(len(data)):     # Repeat The Process for each set of data
    print rows
    # Read from the Data file :##
    sP[0], sP[1], sP[2], vP[0], vP[1], vP[2], SpotType, SpotDim, Overlap, Length, PressureMagnitude, PressureFWHM, FieldType, TempPressPro = data[rows][][][][][][][][][][][][][][]

    ##: Read Model and Part Name :##
    if ModelNm == '1st':
        ModelNm = mdb.models.keys(0)[0]             #: First Model Name

    if len(data[rows])==14:
        print 'No Extras'
        ##: Enter data into Row Function :##
        UStepLen, NewUltimateStep = LPRowBuilder(ModelNm,PartNm,sP,vP,SpotType.strip(), SpotDim, Overlap, Length, PressureMagnitude, PressureFWHM, FieldType.strip(), TempPressPro.strip())

    else:
        print 'Extras'
        Optionals=data[rows][14:]

        def dctBuild(X): return [X.split('=')[0].strip(), X.split('=')[1].strip()]

        Optionals=dict(map(dctBuild,data[rows][14:]))
        ##: Enter data into Row Function :##

        UStepLen, NewUltimateStep = LPRowBuilder(ModelNm,PartNm,sP,vP,SpotType.strip(), SpotDim, Overlap, Length, PressureMagnitude, PressureFWHM, FieldType.strip(), TempPressPro.strip(), **Optionals)

    if ModelNm == '1st':
        ModelNm = mdb.models.keys(0)[0]

if NewUltimateStep != 'Yes':
    prevStepTime = mdb.models[ModelNm].steps['Load-Step'].timePeriod
    mdb.models[ModelNm].steps['Load-Step'].setValues(timePeriod=prevStepTime+UStepLen)
    del mdb.models[ModelNm].steps['Post-Load']

错误:

  

sP [0],sP [1],sP [2],vP [0],vP [1],vP [2],SpotType,SpotDim,Overlap,Length,PressureMagnitude,PressureFWHM,FieldType,TempPressPro = data [行] [:14]

     

ValueError:需要超过0个值才能解压缩

1 个答案:

答案 0 :(得分:0)

变量名称的长度,赋值不匹配。在[]:

之间使用逗号
sP[0], sP[1], sP[2], vP[0], vP[1], vP[2], SpotType, SpotDim, Overlap, Length, PressureMagnitude, PressureFWHM, FieldType, TempPressPro = data[rows], [], [], [], [], [], [], [], [], [], [], [], [], []

就像定义了两个没有值的变量一样。它给出了错误:

a,b = []
# raise ValueError: need more than 0 values to unpack

因为期望a,b

的2个值
a,b = [1,2]
# It is work Fine