gpt4 book ai didi

windows - 相当于 Windows 中的 Unix eval

转载 作者:可可西里 更新时间:2023-11-01 12:41:30 24 4
gpt4 key购买 nike

想知道您如何在 Windows 中执行以下操作:

从 c shell 脚本(扩展名 csh),我在“eval”方法中运行 Python 脚本,以便脚本的输出影响 shell 环境。看起来像这样:

eval `python -c "import sys; run_my_code_here(); "`

想知道如何使用 Windows 的内置 CMD shell 在 Windows 中执行类似 eval 语句的操作。我想在 Windows 脚本中运行 Python 脚本,并让脚本运行 Python 脚本打印出的内容。

** 更新:指定有兴趣从 CMD shell 运行。

最佳答案

如果它在 cmd.exe 中,使用临时文件是唯一的选择 [据我所知]:

python -c "print(\"Hi\")" > temp.cmd
call temp.cmd
del temp.cmd

关于windows - 相当于 Windows 中的 Unix eval,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1195494/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com