码迷,mamicode.com
首页 > 编程语言 > 详细

python学习之——makefiles.py

时间:2015-08-25 16:08:33      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:

# -*- coding: cp936 -*-

import os
#当前平台的行终止符
ls=os.linesep

fname=‘C:\\Users\Administrator\\Desktop\\makefiles.txt‘

#判断文档是否存在,存在则继续,不存在则终止
while True:
if os.path.exists(fname):
print "%s is already exists" %fname
break
else:
break

#文档中输入内容
data=[]
print ". means quit!"
while True:
entry=raw_input(‘>‘)
if entry==‘.‘:
break
else:
data.append(entry)

#写入到文档中
fobj=open(fname,‘w‘)
fobj.writelines([‘%s%s‘%(x,ls) for x in data])
fobj.close()

print ‘DONE‘

python学习之——makefiles.py

标签:

原文地址:http://www.cnblogs.com/cloverclt/p/4757346.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!