ValueError: too many values to unpack - Is it possible to ignore one value?

前端 未结 4 1444
夕颜
夕颜 2020-12-20 19:34

The following line returns an error:

self.m, self.userCodeToUserNameList, self.itemsList, self.userToKeyHash, self.fileToKeyHash = readUserFileMatrixFromFile         


        
4条回答
  •  忘掉有多难
    2020-12-20 20:20

    Just slice the last one out:

    self.m,  self.userCodeToUserNameList, \
    self.itemsList, self.userToKeyHash, \
    self.fileToKeyHash = readUserFileMatrixFromFile(x,True)[:-1]
    

    EDIT after TigerhawkT3's comment :

    Note that this works only if the return object supports slicing.

提交回复
热议问题