如何从bash shell stdin执行脚本代码?

2024-09-25 16:31:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我想从bash标准输入中执行类似python的脚本代码,因为我不想先将脚本编写到文件。怎么办? 如果我想从bash标准输入运行python代码,比如:

#!/usr/bin/env python

print 'hello world'

$cat myode.py | bash-s猫

但没用。错误显示:

Warning: unknown mime-type for "hello world" -- using "application/octet-stream"

错误:没有这样的文件“hello world”


Tags: 文件代码pyenv脚本bashhelloworld