python - 如何在 bash 中提示用户输入?请修复我的 python/bash Spanglish

标签 python bash

抱歉。我对此很陌生,无法找到直接的答案。在 python 中我可以说:

from sys import argv
script, user_name = argv
prompt'> '
print "Hi %s, I'm the %s script" % (user_name, script)
print "I'd like to ask you a few questions"
print "What channel is that on?"
channel = raw_input(prompt)
blah blah -c %r  % (channel)

我需要能够在常规 bash (.sh) shell 脚本中使用 raw_input() 完成同样的事情或者我需要能够在 python 脚本中操作其他程序或者我需要能够从 python 脚本中启动第二个 shell (bash)。

请温柔点。

最佳答案

我猜您正在寻找read内部命令

echo -n "What channel is that on? ";
read channel;

或者更简洁

read -p "What channel is that on? " channel

关于python - 如何在 bash 中提示用户输入?请修复我的 python/bash Spanglish,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8279795/

相关文章:

python - 如何在 PyCharm 中下载文件而不是 Colab 中的 !wget?

python - reshape pandas 数据框的有效方法

python - 在元组中循环直到达到某个索引

python - 执行命令并获取输出

python - 如何自动将相同的答案传递给 subprocess.Popen ?

linux - 计算/枚举按内容过滤的文件夹中的文件

linux - 从 grep 获取特定输出

bash - 从 BASH 中的变量中删除 %0D

bash - 为什么 **find** 找不到任何东西?

linux - Linux :重命名同名不同扩展名的文件