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

老师您好 有个问题想向您请教 #1

Open
a4638966 opened this issue Jun 28, 2020 · 1 comment
Open

老师您好 有个问题想向您请教 #1

a4638966 opened this issue Jun 28, 2020 · 1 comment

Comments

@a4638966
Copy link

a4638966 commented Jun 28, 2020

老师您好 在分页爬取豆瓣图书的时候,遇到一个问题
在循环完成获取到单本书的数据以后,想用list.append把书的信息存到一个列表中用于后续的保存
在存完以后,列表元素的顺序是乱的,没有找到相关说明,请老师帮忙解答一下,感激不尽~~
list.append({book_name,book_path})
在添加完以后元素顺序就乱了

@a4638966 a4638966 reopened this Jun 28, 2020
@fly51fly
Copy link
Owner

是用了多线程吗?多线程情况下每个线程的append动作可能会交错进行,导致顺序错乱,最简单的解决方法,就是把每页的多本书信息一次性append进去

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

2 participants