Python 随笔1
来源:互联网 发布:地方门户cms 编辑:程序博客网 时间:2024/06/07 01:22
最近工作的项目需要用到 python,
好久好久没写过博客了,希望记录下学习python 的历程。
今天写了一个小小的文件转换小程序,把.bat file 转为json文件,
'''
Create 2014/4/28
Be used to transfer bat file to json
author: Sun,Chenhui
'''
import sys,os
def getcurrentpath():
curpath=os.path.dirname(__file__)
print curpath
return curpath
def listcurrentdir(curdir):
for lists in os.listdir(curdir):
path=os.path.join(curdir,lists)
#print path
if os.path.isfile(path):
if path.endswith("bat"):
print path
writeTojs(path)
def writeTojs(batFileName):
import sys, os
contents=open(batFileName).read()
fileToWrite = os.path.splitext(batFileName)[0][0:] + ".js"
output = open(fileToWrite, "w")
output.write(contents)
output.close
print "Successfully to write"+fileToWrite
def main():
listcurrentdir(getcurrentpath())
if __name__ == "__main__":
main()
- Python 随笔1
- python随笔1
- Python随笔1-练习题
- Python随笔(1)
- Python爬虫随笔1
- Python随笔1
- Python 随笔1
- python随笔1(5.22)
- Python随笔
- python 随笔
- python 随笔
- python-随笔
- Python随笔1——字典
- Python初学随笔
- python随笔(一)
- python随笔(二)
- python学习随笔
- Python学习随笔记
- LBP matlab code
- 【树状数组(一)】
- Excel vba中使用vlookup函数
- Facebook中国招聘:研发运营中心有望先行
- shell perl tcl python 和rubby
- Python 随笔1
- 【Android学习笔记】如何添加管理Menu
- jdk环境变量配置
- windows7 旗舰版 不能将程序锁定到任务栏
- 黑马程序员_学习笔记:15) 网络编程:Socket(udp、tcp)
- python shutil模块学习
- NYOJ 137 取石子(三)
- 雅虎推出Firehose正式迈入即时搜索业务市场
- this图解