小编Aja*_*thi的帖子

tflearn 与 tensorflow 2.0

我无法使用 TensorFlow 2.0 导入 tflearn

Python 3.7.4 (v3.7.4:e09359112e, Jul  8 2019, 14:54:52) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
>>> import tflearn
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tflearn/helpers/summarizer.py", line 9, in <module>
    merge_summary = tf.summary.merge
AttributeError: module 'tensorboard.summary._tf.summary' has no attribute 'merge'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import tflearn
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tflearn/__init__.py", line 8, in <module>
    from . …
Run Code Online (Sandbox Code Playgroud)

python python-3.x tensorflow tflearn

5
推荐指数
1
解决办法
2546
查看次数

python asyncio 动态添加任务

我正在Python中学习asyncio,我想尝试使用asyncio。我的目标是连续读取用户的输入并使用该输入创建需要异步运行的作业/任务。

import asyncio
import os
loop = asyncio.get_event_loop()

async def action():
    inp = int(input('enter: '))
    await asyncio.sleep(inp)
    os.system(f"say '{inp} seconds waited'")

async def main():
    while True:
        await asyncio.ensure_future(action())

try:
    asyncio.run(main())
except Exception as e:
    print(str(e))
finally:
    loop.close()
Run Code Online (Sandbox Code Playgroud)

我搞砸了一些事情,我想知道如何实现它。每次用户输入一个数字时,脚本都需要休眠给定的时间,然后说它已经等待了。整个事情需要同时进行。如果用户输入 100 作为输入,脚本应该启动一个任务休眠 100 秒,但在用户端,它需要在用户输入后立即再次请求输入。

python python-asyncio

2
推荐指数
1
解决办法
6430
查看次数

标签 统计

python ×2

python-3.x ×1

python-asyncio ×1

tensorflow ×1

tflearn ×1