本文介绍了从python脚本获取变量作为文件名,并在批处理脚本中使用它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Python脚本,其输出为:目录的最新文件名.
I have a python script which gives the output as: The lastest filename of a directory.
我想在批处理脚本中使用此文件名.我该怎么办?
I want to use this filename in a batch script. How can i able to do it?
推荐答案
您可以使用/f 循环的来获取命令的输出:
You can get the output of a command with a
for /f
loop:
for /f "delims=" %%a in ('command') do set "var=%%a"
用phyton脚本替换
命令
.
replace
command
with your phyton script.
注意:按照书面规定,该变量将包含输出的最后一行(或仅包含一行).
Note: as written, the variable will contain the last line (or only one) of the output.
注意:这是批处理文件语法.如果直接在命令行上使用它,请将每个
%% a
替换为%a
Note: this is batch file syntax. If you use it directly on command line, replace every
%%a
with %a
这篇关于从python脚本获取变量作为文件名,并在批处理脚本中使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!