这是我的代码:
import REQUESTS_MODULE as req
import time
from datetime import datetime
import CSGO_ITEMS as cs
import multiprocessing as mp
start_page = 1
end_page = 500
print(1)
def get_item(market_item):
...
if __name__ == '__main__':
for page in range(start_page, 1000):
pool = mp.Pool(mp.cpu_count())
market_listings = req.request_buff_market_page(page, 'asc', 20, 20.1)
if(market_listings == 0 or page == end_page):
print('\n\n\n\n\n MAX PAGE REACHED: {}'.format(page))
break
for i in range(len(market_listings)-1, 0, -1):
if(market_listings[i][1] < 30 or 'Souvenir' in market_listings[i][0]):
market_listings.pop(i)
pool.map(get_item, market_listings)
cs.workbook.close()
输出:
1
1
1
1
1
1
1
<SpawnProcess(SpawnPoolWorker-1, started daemon)><SpawnProcess(SpawnPoolWorker-2, started daemon)><SpawnProcess(SpawnPoolWorker-6, started daemon)><SpawnProcess(SpawnPoolWorker-3, started daemon)>
我的问题是为什么代码多次打印“ 1”?它只能打印一次。 关于我的代码的其他建议也将不胜感激。