async for的使用
2024-09-04 02:43:33
import random
import asyncio
async def random_number_gen(delay, start, end):
while True:
yield random.randint(start, end)
await asyncio.sleep(delay)
async def main():
async for i in random_number_gen(1, 0, 100):
print(i)
try:
print("Starting to print out random numbers...")
print("Shut down the application with Ctrl+C")
asyncio.run(main())
except KeyboardInterrupt:
print("Closed the main loop..")
最新文章
- Vim命令合集大全
- web移动端资源整(1)
- WPF触发器的使用
- SAP的运输功能(转)
- springMvc源码学习之:spirngMvc获取请求参数的方法
- SQL Server 的事务和锁(一)
- HTML 之 Embed兼容问题
- Review PHP设计模式之——单例模式
- Android开发之屏幕方向
- js编译和执行顺序
- ural 1294 Mars Satellites
- [原]此程序专用来说明C++模板的用法
- weblogic 部署问题定位与解决
- EventBus猜想 ----手把手带你自己实现一个EventBus
- 为Android添加JNI支持
- BZOJ4589 Hard Nim(快速沃尔什变换模板)
- SpringBoot实战一:发送邮件
- Codeforces 359E Neatness
- 20190312 Windows安装Kafka
- Hibernate添加日志--log4j
热门文章
- [NOIP10.4模拟赛]2.y题解--折半搜索+状压计数
- 关于SpringMVC的几件小事
- 可运行jar包转.exe
- HTML Ueditor图片宽度超出编辑器
- python3学习特性
- CDH5.16.1的agent启动报错:ERROR Error, CM server guid updated, expected d9bcadb4-f983-41b8-a667-66760f47bc91, received a67f5efa-8473-4f6a-94d6-231d1f432ef0
- linux——常用命令
- Comparator分组测试
- Python正则及geometer正则截图讲解
- Linux一些常用的命令