gpt4 book ai didi

Python Fabric : How to answer to keyboard input?

转载 作者:IT老高 更新时间:2023-10-28 20:25:04 24 4
gpt4 key购买 nike

我想自动响应某些程序提示的某些问题,例如 mysql 提示输入密码,或 apt 询问"is"或...当我想使用 ./manage 重建我的 haystack 索引时.py 重建索引。

对于 MySQL,我可以使用 --password= 开关,而且我确信 apt 具有类似“安静”的选项。但是如何将响应传递给其他程序?

最佳答案

如果您正在寻找用户确认操作,请使用 confrim 方法。

if fabric.contrib.console.confirm("You tests failed do you want to continue?"):
#continue processing

或者,如果您正在寻找一种从用户那里获取输入的方法,请使用提示方法。

password = fabric.operations.prompt("What is your password?")

关于Python Fabric : How to answer to keyboard input?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2246256/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com