我明白了here我可以从批处理文件调用 python 脚本。
我想要做的是在不使用脚本的情况下调用 python 行。
这是我正在尝试做的一个示例:
>> echo 'python.exe ''' "this/is/a/path".replace('/','\\')''' '
将返回“this\\is\\a\\path”
注意:有一种更简单的方法可以完成我在示例中尝试执行的操作,例如 here但这不是问题:)
最佳答案
您可以使用-c
标志:
Specify the command to execute (see next section). This terminates the option list (following options are passed as arguments to the command).
python -c '''print("this/is/a/path".replace("/","\\"))'''
> this\is\a\path
关于python - 从批处理文件中调用 python 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58972923/