read content in a text file in python
** read text file in python
capability: reading =text= from a text file
1. open the IDLE text editor
>>> idle3
2. declare a *string* variable that holds *the path to the text file*, =test.txt=
>>> strPath="/home/kaiming/Documents/Python/text/text.dat"
3. open the file using the =open()= function
>>> f=open(strPath)
4. Read the contents of the file using the =read()= function
>>> StrText=f.read()
5. Print out the contents of the file
>>> print(strText)
refer to
https://docs.python.org/2/tutorial/inputoutput.html
read content in a text file in python的更多相关文章
- sublime text 3 配置python IDE
Python越来越受“程序猿”们的青睐.快速的开发模式,简洁的代码格式,海量的扩展,这无疑都为python的火热奠定了基础. “磨刀不误砍柴工”,一款功能强劲的IDE能帮助开发者有效的管理.编辑,运行 ...
- 配置 Sublime Text 3 作为Python R LaTeX Markdown IDE
配置 Sublime Text 3 作为Python R LaTeX Markdown IDE 配置 Sublime Text 3 作为Python IDE IDE的基本功能:代码提醒.补全:编译文件 ...
- 把sublime text打造成python交互终端(windows和Ubuntu)
作者:tongqingliu 转载请注明出处:http://www.cnblogs.com/liutongqing/p/7015958.html 把sublime text打造成python交互终端 ...
- sublime text 3 搭建python ide
SublimeCodeIntel 代码提示插件 安装步骤: 1.打开Package Control[Preferences>>Package Control] 2.输入 install 选 ...
- 【Python】Sublime text 3 搭建Python IDE
背景: 最经遇到一件很苦恼的事情,就是在Sublime text 3中写的Python代码直接挪到python原生的ide中老是报格式的错误(有时让人讨厌的缩进),没有办法,看到Sublime tex ...
- sublime text 3搭建python 的ide
感谢大佬-->原文链接 1. 打开Sublime text 3 安装package control Sublime Text 3 安装Package Control 2. 安装 SublimeR ...
- Sublime text 3搭建Python开发环境及常用插件安装 转载
Sublime text 3搭建Python开发环境及常用插件安装 一.环境准备 1.官方网站地址 2.Windows 10 3.Sublime Text 3 + 官网购买license(Just a ...
- windows 下sublime text 3 配置python 环境详解
这我们的环境已经安装了python 3.7.1解释器和sublime text 3 编辑器 一.package control 安装 首先我们打开sublime text 3 ——>Tools— ...
- shell脚本执行时报"bad interpreter: Text file busy"的解决方法
在执行一个shell脚本时,遇到了“-bash: ./killSession.sh: /bin/bash: bad interpreter: Text file busy”错误提示,如下所示: [or ...
随机推荐
- STP-2-三个选择
1.选择根交换机 2.确定根端口 3.确定指定端口 1.选择根交换机 stp中只有一台交换机能成为根(Root),每台交换机按自己的STP逻辑,先发一个hello称自己为根,如果收到了比自 ...
- HDU6301(2018多校第一场)
Bryce1010模板 http://acm.hdu.edu.cn/showproblem.php?pid=6301 队友AC的,没怎么看 #include<iostream> #incl ...
- c#学习系列之Application.StartupPath的用法(美女时钟的做法)
Application.StartupPath是一个只读属性,是不可以设置的. Application.StarupPath获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称.既是Appli ...
- ASP.NET Core MVC/WebAPi 模型绑定
public class Person { public string Name { get; set; } public string Address { get; set; } public in ...
- 【C#】.net 导出Excel功能
将DataSet对象导出成Excel文档 一.不带格式控制 void btnExport_Click(object sender, EventArgs e) { IList<string> ...
- vue使用props动态传值给子组件里的函数用,每次更新,呼叫函数
父组件 <template> <div id="app"> <div>详情内容</div> <button v-on:clic ...
- 7、斐波那契数列、跳台阶、变态跳台阶、矩形覆盖------------>剑指offer系列
题目:斐波那契数列 大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0). f(n) = f(n-1) + f(n-2) 基本思路 这道题在剑指offe ...
- ios has denied the launch request.
ios has denied the launch request. You can choose either of the two ways. Solution 1: Open System Pr ...
- cnblog之初来乍到
hello,大家好,我是蓝斯老师 一枚致力于android开发的攻城狮 很荣幸能够在博客园开博(博主以前是混CSDN的,原博客地址http://blog.csdn.net/lancees) 希望将来能 ...
- mysql命令行执行时不输出列名(字段名)
-N 即可 如:mysql -N -e "select * from test" 摘自:http://blog.csdn.net/eroswang/article/details/ ...