Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
def hello(): return "hello world"
以上是我的python代码。在我输入的外壳中:
fooshell=$(python -c 'import hello; hello.hello()')
但是当我这样做时
echo $fooshell
我得到一个空行。
采用print
print
fooshell=$(python -c 'import hello; print(hello.hello())')
如果您的hello()方法本身不打印到stdout.
hello()
stdout