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. php ftp文件上传函数--新手入门参考

    在 php编程中,用ftp上传文件比较多见,这里分享个简单入门型的ftp上传实例. <?php /** * ftp上传文件 * 学习ftp函数的用法 */ // 定义变量 $local_file ...

  2. Configuration python CGI in XAMPP in win-7

    1.After install XAMPP,we need add the path of the Mysql just find the path and add it to your sys-pa ...

  3. Color About——Second

    下面来简要的说一下Android开发中如何对某一个Activity进行背景色的设置.下面我以名字为FirstActivity的Activity的背景色的设置进行说明,先说一下Drawable类: 关于 ...

  4. 使用微软分布式缓存服务Velocity(Windows Server AppFabric Caching Service)

    概述 Velocity是微软推出的分布式缓存解决方案,为开发可扩展性,可用的,高性能的应用程提供支持,可以缓存各种类型的数据,如CLR对象. XML.二进制数据等,并且支持集群模式的缓存服务器.Vel ...

  5. IIS WMI Provider

    section contains information about the classes that are implemented by the IIS WMI provider in the M ...

  6. IOS开发之──应用之间调用(1)

    iphone应用之间调用步骤: 1)在plist文件中,注册对外接口 在xcode group&files 里面,展开 resources选择<app>info.plist 鼠标右 ...

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

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

  8. Extjs 4.2 grid 分页问题,点击下一页参数没带过去

    最初的store写法: var store = Ext.create('Ext.data.Store', { model: 'PKU',//这个地方CarPKU不是一个对象,而是一个类 remoteS ...

  9. 关于qt5在win7下发布 & 打包

    QT5 发布时,莫过于依赖动态链接库(dll) , 但是,QT5的动态链接库貌似都有2套 ,例如 Qt5Core (针对realese) , Qt5Cored (针对debug) ,凡事末尾带d的都是 ...

  10. java解析xml禁止校验dtd

    参考: http://shansun123.iteye.com/blog/1020425 http://blog.csdn.net/hailanzhijia/article/details/60049 ...