ValueError: need more than 1 value to unpack python

后端 未结 4 1341
抹茶落季
抹茶落季 2020-12-06 18:01

I have got an existing menu that gives you options L or D. L should load the contents of a file and D should display it.<

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-06 18:44

    This error is occurring at

    name,adult,child= line.split(',')
    

    When you assign three variables on the left it is assuming you have a 3-tuple on the right. In this example, it appears line has no comma hence line.split(',') results in a list with only one string, thus the error "more than 1 value to unpack".

提交回复
热议问题