Home  >  Article  >  Backend Development  >  批处理与python代码混合编程的方法

批处理与python代码混合编程的方法

WBOY
WBOYOriginal
2016-06-10 15:04:451360browse

批处理可以很方便地和其它各种语言混合编程,除了好玩,还有相当的实用价值,比如windows版的ruby gem包管理器就是运用了批处理和ruby的混合编写,bathome出品的命令工具包管理器bcn 使用了bat+jscript的混编实现的。

cn-dos和bathome论坛里先后有帖子介绍和示范了批处理和各种语言脚本的混合编程,有兴趣可以搜索看看。

python不挑剔文件后缀,只要程序中包含正确的python代码都可以用python 解释器解释执行。

批处理与python的混合编程方法很简单,存为xx.bat,代码如下:

"""
::=================这是注释
::批处理与python程序的混合编程
::2016年5月18日 14:26:03 codegay
::下面写批处理代码
@echo off&cls
echo batch echo
python.exe %0&pause
::=================这是注释
"""
#下面写你的python代码
print("python print")
#如果需要python输出中文,需要把文件存为UTF8
print("中文")

以上所述是小编给大家介绍的批处理与python代码混合编程的方法的相关知识,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn