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()方法来通过资源路径检索外部资源.从而将 ...
随机推荐
- Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- C++ Primer : 第十章 : 泛型算法 之 只读、写和排序算法
大多数算法都定义在<algorithm>头文件里,而标准库还在头文件<numeric>里定义了一组数值泛型算法,比如accumulate. ● find算法,算法接受一对迭代 ...
- ubuntu14.04 and ros indigo install kinect driver--16
摘要: 原创博客:转载请表明出处:http://www.cnblogs.com/zxouxuewei/ 今日多次测设ros indigo install kinect driver ,提示各种失败,然 ...
- 固定虚拟机的IP
- hdu2647 拓扑序
题意:年终要给 n 个员工发奖金,每个人的起始金额是888,有些人觉得自己做的比另一个人好所以应该多得一些钱,问最少需要花多少钱,如果不能满足所有员工的要求,输出 -1 拓扑排序,从奖金少的向奖金多的 ...
- IOS 开发qq登陆界面
// // ViewController.m // QQUI_bydfg // // Created by Kevin_dfg on 16/4/15. // Copyright © 2016年 ...
- ARM1138@PWM例程分析
1. Buzzer例程控制原理 由ARM1138原理图可得:Buzzer使用CCP3(对应GPIO-G组0x40026000,4号引脚0x00000010)作为输入引脚: Buzzer例程结构: 涉及 ...
- Linux驱动设计—— 中断与时钟@request_irq参数详解
request_irq函数定义 /*include <linux/interrupt.h>*/ int request_irq(unsigned int irq, irq_handler_ ...
- Android度量单位说明(DIP,DP,PX,SP)
本文转载于:http://blog.sina.com.cn/s/blog_6b26569e0100xw6d.html (一)概念 dip: device independent pixels(设备独立 ...
- java 读取文件的字节数组
/*文件64位编码*/ public static void main(String[] args) { byte[] fileByte = toByteArray(newFile); St ...