抱歉。我对此很陌生,无法找到直接的答案。在 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/