【发布时间】:2012-10-01 03:02:51
【问题描述】:
我想将 shell 输入传递给 python 中的变量。通常我会为此使用raw_input() 方法,但我想使用一些允许我“浏览”文件夹的东西。
在 bash 脚本中,我会使用如下内容:(-e 允许我通过 Tab 使用 shell 的“自动完成”功能。)
#!/bin/bash
echo Please input the path to the file:
read -e var
echo $var
有谁知道如何用 Python 解决这个问题?我查看了os.popen() 和os.system(),但不知道如何使用它们。
【问题讨论】:
标签: python bash variables autocomplete