繁体   English   中英

问题通过.bat 文件将输入传递给 python 脚本

[英]Issue passing input to python script via .bat file

我想运行一个使用 python 脚本的批处理文件。 python 脚本需要一个日期作为键输入。

我根据我在这里看到的内容尝试了以下操作( 将 arguments 从批处理文件发送到 Python 脚本

@echo off
set /p data_valori=Insert date (format yyyy/mm/dd) :
"C:\Program Files\Anaconda3\python.exe" "S:\pricing\Python\new scarico Market Data ASW_PER_DATA_CUSTOM.py" %data_valori%

我的 python 脚本然后执行以下操作:

import sys
data_valori = str(sys.argv[1])

I manage to insert the input in the cmd window but then it never calls python (from what I see) and it just closes the cmd window.

我尝试了不同的选项来调用 python,例如

python new scarico Market Data ASW_PER_DATA_CUSTOM.py %data_valori%

输入后仍然关闭cmd。

在批处理脚本末尾添加pause有助于捕获 python 脚本中的错误

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM