在Windows shell命令中embeddedPython代码

我如何将一个小的Python脚本embedded到Windows shell命令中以向程序提供参数

例:

C:\> hello Bob Welcome Bob! 

我需要的是这样的:

 C:\> hello 'python -c print('Bob')' Welcome Bob! 

谢谢!

Powershell支持与bash相同的格式,所以你可以这样做:

 PS C:\> hello $(python -c "print('Bob')") 

对于cmd.exe ,没有这样的等价物,但你可以试试这个(未经测试):

 C:\>FOR /F "usebackq" %x in (`python -c "print('Bob')"`) DO hello %x