Linux Primer

Dive into linux kernel

Using Bat File to Run Python Program on Windows

| Comments

在windows下批处理文件中调用python

由于python的变量的问题,不能在批处理文件somefile.bat正确使用python somefile.py来执行python程序。

所以需要在bat文件中临时修改python环境变量。

最终的bat文件如下:

1
2
3
4
5
6
7
8
9
10
@echo off
set PYPATH=C:\Python27;C:\Python27\Lib;C:\Python27\libs;C:\Python27\Tools\Scripts;
set path=%PYPATH%;%path%
@echo on

python get_all_problems.py
python get_need_solved.py
python sort_problems.py

pause

Comments