We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
列表并行排序,原来的代码
data = zip(list1, list2) data.sort() list1, list2 = map(lambda t: list(t), zip(*data))
python3中报错: AttributeError: 'zip' object has no attribute 'sort'
应该改为
data = zip(list1, list2) data = sorted(data) list1, list2 = map(lambda t: list(t), zip(*data))
这是因为在python2中zip()返回的是list类型,而在python3中返回的是zip类型(一种可迭代类型),所以不能用sort(),而应该改为sorted()。
P.S. 原库 intermediatePython 目前也有这个问题
The text was updated successfully, but these errors were encountered:
谢谢, 还把解决方案都拿出来了, 可以直接提PR的 👍
已改 933c9d2
Sorry, something went wrong.
No branches or pull requests
列表并行排序,原来的代码
python3中报错:
AttributeError: 'zip' object has no attribute 'sort'
应该改为
这是因为在python2中zip()返回的是list类型,而在python3中返回的是zip类型(一种可迭代类型),所以不能用sort(),而应该改为sorted()。
P.S. 原库 intermediatePython 目前也有这个问题
The text was updated successfully, but these errors were encountered: