Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zip函数 not enough values to unpack (expected 2, got 0) #173

Open
wudaism opened this issue May 17, 2024 · 0 comments
Open

zip函数 not enough values to unpack (expected 2, got 0) #173

wudaism opened this issue May 17, 2024 · 0 comments

Comments

@wudaism
Copy link

wudaism commented May 17, 2024

运行Data_util.py
Traceback (most recent call last):
File "e:\python\chatbot\Chatbot-tensowflow2.0\Seq2seqchatbot\data_util.py", line 72, in
input_lang, target_lang = zip(*word_pairs)
ValueError: not enough values to unpack (expected 2, got 0)

查询type(zip(*word_pairs)) <class 'zip'>
这里的错误是我版本不对吗
查询zip用法

a = [1,2,3]
b = [4,5,6]
c = [4,5,6,7,8]
zipped = zip(a,b) # 返回一个对象
zipped
<zip object at 0x103abc288>
list(zipped) # list() 转换为列表
[(1, 4), (2, 5), (3, 6)]
list(zip(a,c)) # 元素个数与最短的列表一致
[(1, 4), (2, 5), (3, 6)]

a1, a2 = zip(zip(a,b)) # 与 zip 相反,zip() 可理解为解压,返回二维矩阵式
list(a1)
[1, 2, 3]
list(a2)
[4, 5, 6]

这里如何修改

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant