python按行读取文件,如何去掉换行符"\n"

for line in file.readlines():
line=line.strip('\n')

python没有substr,但可以用slice

s = line[11:22]

遍历文件夹。os.walk()返回一个三元素的tuple:当前路径、子文件夹名称、文件列表。

import os
def fun( path ):
for root, dirs, files in os.walk( path ):
for fn in files:
print root, fn

  

  

Python Snippet的更多相关文章

  1. A look at WeChat security

    原文地址:http://blog.emaze.net/2013/09/a-look-at-wechat-security.html TL;DR: Any (unprivileged) applicat ...

  2. How to Use Postman to Manage and Execute Your APIs

    How to Use Postman to Manage and Execute Your APIs Postman is convenient for executing APIs because ...

  3. vim中自动补全插件snipmate使用

    vim中自动补全插件snipmate使用 1.下载snipMatezip:https://github.com/msanders/snipmate.vim/archive/master.zip 2.解 ...

  4.  Go is more about software engineering than programming language research.

    https://talks.golang.org/2012/splash.article Go at Google: Language Design in the Service of Softwar ...

  5. Snippet: Fetching results after calling stored procedures using MySQL Connector/Python

    https://geert.vanderkelen.org/2014/results-after-procedure-call/ Problem Using MySQL Connector/Pytho ...

  6. Coroutines declared with async/await syntax is the preferred way of writing asyncio applications. For example, the following snippet of code (requires Python 3.7+) prints “hello”, waits 1 second, and

    小结: 1.异步io  协程 Coroutines and Tasks — Python 3.7.3 documentation https://docs.python.org/3/library/a ...

  7. sublime text添加snippet

    下面的${1:this}格式的会在tab键下一次切换选中 <snippet> <content><![CDATA[Hello, ${1:this} is a ${2:sn ...

  8. 手把手教你写Sublime中的Snippet

    手把手教你写Sublime中的Snippet Sublime Text号称最性感的编辑器, 并且越来越多人使用, 美观, 高效 关于如何使用Sublime text可以参考我的另一篇文章, 相信你会喜 ...

  9. 转帖:Python应用性能分析指南

    原文:A guide to analyzing Python performance While it’s not always the case that every Python program ...

随机推荐

  1. windows store app 读写图片

    using System; using System.Threading.Tasks; using System.Runtime.InteropServices.WindowsRuntime; usi ...

  2. ClickOnce证书签名

    打开Microsoft .NET Framework 的SDK命令提示,按以下步骤操作: 1.创建一个自我签署的X.509证书(.cer)和一个.pvk私钥文件,用到makecert工具,命令如下: ...

  3. C# winform 中 TabControl 动态显示 TabPage

    在winform应用中,tabcontrol是一个很好的控件,可以根据需求提供多个选项卡(TabPages),但是有一个问题是当某个项目需要多个选项卡,但是不同的功能要求显示不同的选项卡,其他的非该功 ...

  4. windows程序消息机制(Winform界面更新有关)

    windows程序消息机制(Winform界面更新有关) 转自:http://www.cnblogs.com/blosaa/archive/2013/05/31/3109586.html 1. Win ...

  5. mysql手工注入

    以下是mynona本人原创的,奉献给大家,不要小看数据库注入 参考: http://www.daydaydata.com/help/sql/advance/limit.html http://www. ...

  6. Selenium 入门

    我本身也是一个初学者,就顺手记录一下自己的成长记录,共勉 1, 登录selenium官方网站,download 相关的插件. http://docs.seleniumhq.org/ 我用的是eclip ...

  7. Install mcrypt for php on Mac OSX 10.10 Yosemite for a Development Server

    mcrypt is a file encryption method using secure techniques to exchange data. It is required for some ...

  8. NGUI3.5系列教程之 一些小功能的实现

    (一)可拖动窗体的实现: 1:添加一个Sprite为鼠标点击区域,改名为:DragSprite 2:给DragSprite添加Collider 3:给DragSprite添加Drag Object , ...

  9. Spring中后台字符串国际化

    1.在工程的资源文件夹(source folder)中建立三个properties文件:messages.properties(默认).messages_zh_CN.properties(中文).me ...

  10. Daily Scrum 11.12

    摘要:本次会议继续讨论程序的问题以及单元测试和集成测试,本次测试为终审,并且本次得到的为alpha版本的最终版本.本次的Task列表如下: Task列表 出席人员 Today's Task Tomor ...