简体   繁体   中英

ValueError:too many values to unpack

I'm a beginner and, when I try to transform date time to mins, I get the error:

ValueError: too many values to unpack

Here's my code:

def t2m(t):
    m,s,l = t.strip().split(":")
    return int(m)+int(s)/60+int(l)/6000

a= "0000-00-00 00:12:46:13"
d=a.strip('0000-00-00 00')

print(round(t2m(d)),1) 

You are getting the error because t.strip().split(":") returns 4 values and you are trying to put them into m,s,l .

You should replace your second line with:

_,m,s,l = t.strip().split(":")

found out by myself. should be like

d=a.strip('0000-00-00 00:')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM