【问题标题】:How to check two mule running status in python如何在python中检查两个骡子的运行状态
【发布时间】:2020-06-08 14:35:19
【问题描述】:

谁能帮我把下面的python代码修改成一个return语句?

return any("is running" in x for x in response.splitlines()) <br>
return any("active (running)" in x for x in response.splitlines())

我尽了最大努力,但最终得到了“SyntaxError: Generator expression must be parenthesized if not sole argument”。

提前致谢!

【问题讨论】:

  • 只需像这样将"is running" in x for x in response.splitlines() 包裹在[] 周围:any(["is running" in x for x in response.splitlines()])
  • 感谢您的快速回复。检查第二个条件“活动(运行)”是否有帮助?

标签: python python-3.x python-2.7 python-requests


【解决方案1】:

return any("is running" or "active (running)" in x for x in response.splitlines())

这个很好用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-24
    • 1970-01-01
    • 2013-01-05
    • 1970-01-01
    • 2014-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多