我使这个简单的.bat
批处理文件包含
@echo off
set log=mainLog.txt
cd /d F:/Project/Python
echo [%TIME%]starting main.py >%log%
python main.py >> %log%
命令提示符成功地将main.py
输出重定向到日志文件,但没有在提示屏幕上显示。所以我把它改成:
这将向提示屏幕显示main.py
的输出,但不会重定向到日志文件。我已经试过使用:
python main.py 2>> %log% 1>> %log%
但这给了我:
The Process cannot access the file because it is being used by another process
假设我的main.py
包含:
for i in range(10):
print("this is line no. {}".format(i))
有什么办法吗?在
使用键入在提示中调用和显示文件(仅文本)
阅读更多如何使用类型-@SS64 - Type Command。在
(例如)
此脚本输出到日志,但您需要调用输出日志以在提示时显示。在
相关问题 更多 >
编程相关推荐