通过bat脚本的注释rem
以及python脚本的注释"""
实现将python脚本嵌入到bat脚本中执行。
将python语句嵌入到bat脚本中,直接执行bat脚本的最终结果是执行python脚本。
python脚本可以接收bat脚本的命令行输入参数。
主要用到三个技巧:
- bat的注释
rem
- python的多行注释
"""
- bat的goto label
PythonScriptInBatview raw1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| @echo off python.exe -d %0 %* pause goto endofPython """ import os import sys print "hello,python " print "pwd: " + os.getcwd()
for i in range(0, len(sys.argv)): print "argv", i, sys.argv[i]
:endofPython """
|