Python-文件输入和输出
来源:互联网 发布:java读取xml文件内容 编辑:程序博客网 时间:2024/06/13 15:03
这是我第一个Python程序-文件的输入:
import osls = os.linesep#get filenamefname = raw_input()while True: if os.path.exists(fname): print "error:'%s' already exists" %(fname) else: breakall = []print "\n enter lines: \n"while True: entry = raw_input('>') if entry == '.': break else: all.append(entry)fobj = open(fname,'w')fobj.writelines(['%s%s' %(x,ls) for x in all])fobj.close()print "DONE !"
输入地址,检查是否存在,以单行输入“.”结束。
文件输出到CMD框:
fname = raw_input('Enter Filename:')try: fobj = open(fname,'r')except Exception as e: print "*** file open error",eelse: for eachLine in fobj: print eachLine fobj.close()finally: pass
输入文件地址,输出到屏幕。
有什么问题请联系我:839505138.
阅读全文
0 0
- python文件输入和输出
- python 文件输入和输出
- Python-文件输入和输出
- Python开发-Python文件处理-Python文件输入和输出
- python 输入、输出、文件
- python 输入和输出
- python输入和输出
- Python输入和输出
- Python 输入和输出
- Python输入和输出
- 文件输入 和 输出
- 【Python】 Python输入和输出
- python的输入和输出
- python 指南 输入和输出
- Python学习 - 输入和输出
- python 3 输入和输出
- Python的输入和输出
- [python基础] 输入和输出
- Validate Binary Search Tree
- 安装slowhttptest各种问题解决方案
- 微信js-sdk分享详解及demo实例
- hdu1754 I Hate It
- 数据加密---简单的int类型数据转化到一维数组中
- Python-文件输入和输出
- 傅立叶变换学习(一)初步认识傅立叶变换
- PHP函数stream_context_create()模拟POST/GET
- HDU-Kanade's sum-模拟
- 分享一款Android开源的仿IOS滚轮效果的控件
- HDU 6121 思维 + DFS
- nyoj 18 The Triangle
- 解决引入Dragger2时的等注入依赖报的错: Gradle DSL method not found: 'apt()'
- ClippingNode