ValueError:没有足够的值可解包(预期11,得到1) [英] ValueError: not enough values to unpack (expected 11, got 1)

查看:160
本文介绍了ValueError:没有足够的值可解包(预期11,得到1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个用于系统自动化的脚本,但是出现标题中描述的错误.我下面的代码是脚本的相关部分.有什么问题吗?

I wrote a script for system automation, but I'm getting the error described in the title. My code below is the relevant portion of the script. What is the problem?

import csv
import os

DIR = "C:/Users/Administrator/Desktop/key_list.csv"

def Customer_List(csv):
    customer = open(DIR)
        for line in customer:
            row = []
            (row['MEM_ID'],
             row['MEM_SQ'],
             row['X_AUTH_USER'],
             row['X_AUTH_KEY'],
             row['X_STORAGE_URL'],
             row['ACCESSKEY'],
             row['ACCESSKEYID'],
             row['ACCESSKEY1'],
             row['ACCESSKEYID1'],
             row['ACCESSKEY2'],
             row['ACCESSKEYID2'])=line.split()
            if csv == row['MEM_ID']:
                customer.close()
                return(row)
            else:
                print ("Not search for ID")
                return([])

id_input = input("Please input the Customer ID(Email): ")
result = Customer_List(id_input)

if result:
    print ("iD:    " + id['MEM_ID']

推荐答案

在线

line.split()

您打算做什么?看起来像CSV,所以请尝试

What are you splitting on? Looks like a CSV, so try

line.split(',')

示例:

"one,two,three".split()  # returns one element ["one,two,three"]
"one,two,three".split(',')  # returns three elements ["one", "two", "three"]

如@ TigerhawkT3所述,最好使用CSV模块. 此处.

As @TigerhawkT3 mentions, it would be better to use the CSV module. Incredibly quick and easy method available here.

这篇关于ValueError:没有足够的值可解包(预期11,得到1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆