Python 从sketch中读取文件
=============================== RESTART: Shell ===============================
>>> import os
>>> os.getcwd()
'C:\\Windows\\System32'
>>> os.chdir('C:/Users/eric/Documents/Python')
>>> os.getcwd()
'C:\\Users\\eric\\Documents\\Python'
>>> data = open ('sketch.txt')
>>> print (data.readline(),end='')
Man: Is this the right room for an argument?
>>> print (data.readline(),end='')
Other Man: I've told you once.
>>> data.seek(0)
0
>>> for each_line in data:
print(each_line, end='') Man: Is this the right room for an argument?
Other Man: I've told you once.
Man: No you haven't!
Other Man: Yes I have.
Man: When?
Other Man: Just now.
Man: No you didn't!
Other Man: Yes I did!
Man: You didn't!
Other Man: I'm telling you, I did!
Man: You did not!
Other Man: Oh I'm sorry, is this a five minute argument, or the full half hour?
Man: Ah! (taking out his wallet and paying) Just the five minutes.
Other Man: Just the five minutes. Thank you.
Other Man: Anyway, I did.
Man: You most certainly did not!
Other Man: Now let's get one thing quite clear: I most definitely told you!
Man: Oh no you didn't!
Other Man: Oh yes I did!
Man: Oh no you didn't!
Other Man: Oh yes I did!
Man: Oh look, this isn't an argument!
(pause)
Other Man: Yes it is!
Man: No it isn't!
(pause)
Man: It's just contradiction!
Other Man: No it isn't!
Man: It IS!
Other Man: It is NOT!
Man: You just contradicted me!
Other Man: No I didn't!
Man: You DID!
Other Man: No no no!
Man: You did just then!
Other Man: Nonsense!
Man: (exasperated) Oh, this is futile!!
(pause)
Other Man: No it isn't!
Man: Yes it is!
>>> data.close()
>>>
Python 从sketch中读取文件的更多相关文章
- python 按每行读取文件怎么去掉换行符
python按每行读取文件后,会在每行末尾带上换行符,这样非常不方便后续业务处理逻辑,需要去掉每行的换行符,怎么去掉呢?看下面的案例: >>> a = "hello wor ...
- 文件_ _android从资源文件中读取文件流并显示的方法
======== 1 android从资源文件中读取文件流并显示的方法. 在android中,假如有的文本文件,比如TXT放在raw下,要直接读取出来,放到屏幕中显示,可以这样: private ...
- 用adb pull命令从android系统中读取文件失败的原因及解决办法
问题:使用adb pull命令从android系统中读取文件失败.显示:Permission denied 原因:是由于文件权限原因引起. 使用ls -l命令查看android系统中的 ...
- Java中读取文件
Java中读取文件,去除一些分隔符,保存在多维数组里面 public void readFile(String filePath) { File file=new File(filePath); Ar ...
- 如何配置一个路径,能够既适合Linux平台,又适合Windows平台,可以从这个路径中读取文件
如何配置一个路径,能够既适合Linux平台,又适合Windows平台,可以从这个路径中读取文件? 目的:就是希望在项目的配置文件中配上一样的路径,不管协作者使用的是什么平台,都能够读到文件. 比如:L ...
- PHP中读取文件的几个方法
整理了一下PHP中读取文件的几个方法,方便以后查阅. 1.fread string fread ( int $handle , int $length ) fread() 从 handle 指向的文件 ...
- R中读取文件,找不到路径问题 No such file or directory
R中读取文件,找不到路径问题 No such file or directory 近日,读取文件时.出现例如以下问题 > passenger = read.csv('internationa ...
- php中读取文件内容的几种方法。(file_get_contents:将文件内容读入一个字符串)
php中读取文件内容的几种方法.(file_get_contents:将文件内容读入一个字符串) 一.总结 php中读取文件内容的几种方法(file_get_contents:将文件内容读入一个字符串 ...
- Spring 中读取文件-ResourceLoaderAware
Spring 中读取文件-ResourceLoaderAware 概述 Spring ResourceLoader为我们提供了一个统一的getResource()方法来通过资源路径检索外部资源.从而将 ...
随机推荐
- R 学习1
首先安装吧 http://cran.rstudio.com/bin/windows/base/R-3.2.1-win.exe 里面既有32位又有64. R有很多包,如果有的包本地没有,来这里搜 htt ...
- linux信号处理及libcurl的坑
前言: 最近有个项目, 需要访问第三方服务. 该服务是通过http的形式访问的, 为了安全和加密, 对方提供了一个加密用的C/C++库, 用于对参数进行处理. 鉴于此, 选用了C/C++语言 ...
- javaio-printwriter
转自http://www.cnblogs.com/skywang12345/p/io_25.html PrintWriter 介绍 PrintWriter 是字符类型的打印输出流,它继承于Writer ...
- Android SDK Manager Google Apis 下载
本意是想利用google的gcm来实装android推送功能的,很遗憾, google貌似已经停止提供啥服务给国内了,或者说国内想继续使用google 服务暂时变得几乎不可能了.找了个代理来进行goo ...
- 信頼済みサイト对window.open窗体大小影响原因之一
如果某站点被添加进去之后,这个站点窗体限制被决定了,window.open里面,status bar 无效的设置不再起作用.而且,如果原来status bar被 任务栏挡住的话,这个时候它就会被显示出 ...
- jquery的ajax异步请求接收返回json数据
http://www.jb51.net/article/51122.htm jquery的ajax异步请求接收返回json数据方法设置简单,一个是服务器处理程序是返回json数据,另一种就是ajax发 ...
- leetcode 142. Linked List Cycle II ----- java
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note ...
- JavaWeb学习记录(五)——Servlet随机产生验证码
随机产生验证码的工具类: import java.awt.Color;import java.awt.Graphics;import java.awt.image.BufferedImage;impo ...
- Apache的虚拟主机配置
使用虚拟主机要先取消中心主机,注释掉DocumentRoot #DocumentRoot "/www/htdoc" 虚拟主机的单独配置: 用户认证 访问日志 错误日志 别名 脚本别 ...
- 铺地毯 2011年NOIP全国联赛提高组
题目描述 Description 为了准备一个独特的颁奖典礼,组织者在会场的一片矩形区域(可看做是平面直角坐标系的第一象限)铺上一些矩形地毯.一共有n 张地毯,编号从1 到n.现在将这些地毯按照编号从 ...