Python 3 - ValueError: not enough values to unpack (expected 3, got 2)

前端 未结 5 2082
野的像风
野的像风 2021-01-04 14:04

I have a problem with my Python 3 program. I use Mac OS X. This code is running properly.

# -*- coding: utf-8 -*-
#! python3
# sendDuesReminders.py - Sends e         


        
5条回答
  •  逝去的感伤
    2021-01-04 14:42

    You probably want to assign the lastname you are reading out here

    lastname = sheet.cell(row=r, column=3).value
    

    to something; currently the program just forgets it

    you could do that two lines after, like so

    unpaidMembers[name] = lastname, email
    

    your program will still crash at the same place, because .items() still won't give you 3-tuples but rather something that has this structure: (name, (lastname, email))

    good news is, python can handle this

    for name, (lastname, email) in unpaidMembers.items():
    

    etc.

提交回复
热议问题