它说
james.append(sanitize(each_item))
(mins, secs) = time_string.split(splitter)
need more than 1 value to unpack
怎么了?谢谢你。这是 Head First Python 中的示例
james = []
def sanitize(time_string):
if '-' in time_string:
splitter = '-'
elif ':' in time_string:
splitter = '-'
else:
splitter = ','
(mins, secs) = time_string.split(splitter)
return(mins + '.' + secs)
with open('james.txt', 'r') as jaf:
data = jaf.readline()
james_data = data.strip().split(',')
for each_item in james_data:
james.append(sanitize(each_item))
sort(james)
print(james)