编程语言
首页 > 编程语言> > python – Pylint警告:可能不平衡的元组用序列解包

python – Pylint警告:可能不平衡的元组用序列解包

作者:互联网

我有一段Python代码:

def func1():                                                                                                                  
    a=set()
    b = ','.join(map(str, list(a)))
    return  b, []

def func2():
    d = 1
    e = 2
    return func1() + (d, e,)

def main():
    a,b,c,d = func2()

if __name__ == '__main__':
    main()

当我通过pylint(1.4.0)运行它时,我收到警告:

W: 12, 4: Possible unbalanced tuple unpacking with sequence: left side has 4 label(s), right side has 3 value(s) (unbalanced-tuple-unpacking)

似乎func2将始终返回四个结果.错误是什么意思?为什么?

解决方法:

在带有错误的行之后添加#pylint:disable = unbalanced-tuple-unpacking.为我工作

标签:python,tuples,pylint,packing
来源: https://codeday.me/bug/20190703/1361744.html