Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
486 views
in Technique[技术] by (71.8m points)

python - I'm really stuck with for loops asyncio

I am really stuck with this asyncio for 4 days, read a lot of articles, documents and watched a lot videos still don't understand. Can anyone help me convert this code to asynchronous? and if asynchronous tasks be more than 1 (3-4 enough) that would be great thanks a lot.

IMPORTANT NOTE: Please don^'t use await async.sleep(), probably the reason why I'm so confused that's because of everyone using await async.sleep(). I really hate await async.sleep(), I need real examples.

import datetime

def find_divisibles2(inrange, div_by):
    start=datetime.datetime.now()
    print("finding nums in range {} divisible by {}".format(inrange, div_by))
    located = []
    for i in range(inrange):
        if i % div_by == 0:
            r=located.append(i)
    print("Done w/ nums in range {} divisible by {}".format(inrange, div_by))
    finish=datetime.datetime.now()
    print(finish-start)


find_divisibles2(90000000,5163)
question from:https://stackoverflow.com/questions/65546063/im-really-stuck-with-for-loops-asyncio

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...