python where to find files which do not contain a string line

2011-04-27  来源:本站原创  分类:Python  人气:79 

>>> Data = file ("test.txt"). Readlines ()
>>> Res_data = filter (lambda x: '292 10.120.10.1 'not in x, data)
>>> Res_data
['Dadfadfasadasd']
>>>

相关文章
  • python where to find files which do not contain a string line 2011-04-27

    >>> Data = file ("test.txt"). Readlines () >>> Res_data = filter (lambda x: '292 10.120.10.1 'not in x, data) >>> Res_data ['Dadfadfasadasd'] >>>

  • Python source code encoding declaration in the role of the string 2010-10-15

    Python source code that compiled the original head of the # encoding: utf8 string parsing code for the python is no actual impact. But today found a very interesting question. Mark it. When the python code in a similar u 'Chinese' when such a string,

  • python to print all files 2010-04-16

    1. def find_file_by_pattern(pattern='.*', base=".", circle=True): 2. ''''' Find all the given folder the following ''' 3. re_file = re.compile(pattern) 4. if base == ".": 5. base = os.getcwd() 6. 7. final_file_list = [] 8. print base 9

  • python utf-8 encoding generated files 2011-04-23

    import codecs f = codecs.open ("html / report.html", "w", "utf-8") f.write ( tmpl.render (result) ) f.close ()

  • Ruby win32ole xls files to achieve the insertion of hollow line 2010-06-11

    A while ago, with Ruby's win32ole write a script for data analysis and summary to the xls, the need to insert a blank line separating the upper and lower data form. excel = WIN32OLE::new('excel.Application') workbook = excel.Workbooks.Open(RESULT + "

  • Linux Learning Path - Batch Replace all files in the directory of a string 2010-11-18

    The first step: touch replace Which replace the file name, this just named. Step Two: vim replace Write the following code and replace the for i in `grep -l -r 'opt' * `;do sed 's/home\/sky/opt/g' $i>junk mv junk $i done Function is the home / sky st

  • A more detailed description of the DOS command (turn) 2010-12-30

    A more detailed description of the DOS command ! 2007-09-14 13:00 A more detailed description of the DOS command ! 2007 August 30 Thursday Afternoon 09:11 Article from :cfan, View original . 1 echo And @ Echo command @ # Off-line echo echo off # Star

  • Examples of backup files windows python implementation 2010-06-02

    Examples of backup files in python under windows use winrar to rar command can run successfully, only to have the software winrar and set the environment variables. # Filename: backup_ver4.py import os import time # 1. Want to make a backup copy of t

  • Letters python learning 2010-03-04

    This is an enormous part of the following "Python core programming (English Second Edition)" this book. print statement calling str () function display objects, while the interactive interpreter call the repr () function to display the object; _

  • Traverse the directory using python 2010-03-10

    Requirements: traverse directory using python, and catalog all files saved to the txt file. #getFilesName # -*- coding: cp936 -*- import os import re import gl gl.rootdir = os.getcwd() outfilename = gl.rootdir + '\\allfilenames.txt' ''' The file name

  • Python HTTP file upload 2010-05-06

    # -*- coding:UTF-8 -*- ''' Created on 2010-4-26 @author: shiyong ''' import urllib import sys import urllib2 import mimetools, mimetypes import os, stat from IdongNet import IdongNet from UserManager import UserManager import cookielib class Callable

  • Input and output functions with Python to read and write data 2010-05-27

    http://apps.hi.baidu.com/share/detail/970052 from: IBM Read, write and Python In the " Explore Python "series of the previous article, learning the basic Python data types and a number of container data types, such as tuple, string and list. Oth

  • Python 2.5 Quick Reference 2010-06-21

    Python 2.5 Quick Reference Collection <script type="text/javascript"> document.body.oncopy = function () (if (window.clipboardData) (setTimeout (function () (var text = clipboardData.getData ("text"); if (text & ; & text.

  • Using Python for web analytics to achieve bulk download 2010-07-30

    Final version: previous version (see my previous article) are basically matching using regular expressions to achieve the download link, has two drawbacks: 1. Given the very laws of the page, so regular expressions are too cumbersome to achieve them,

  • Concise Notes on Python Tutorial 2010-08-03

    A kind of static type language during the compilation of data to determine the type of language. Most statically typed language is by requiring the use of any of its data type variable is declared before to ensure this. Java and C are statically type

  • Simple Python Tutorial notes of reading 2010-08-03

    A kind of static type language during the compilation of data to determine the type of language. Most statically typed language is by requiring the use of any of its data type variable is declared before to ensure this. Java and C are statically type

  • Register your Python distribution to Windows registry 2010-10-27

    Register your Python distribution to Windows registry Open the registry to HKLM-SOFTWARE-Python-PythonCore New items for the Python version number, such as 2.6. The first version of the new items InstallPath, PythonPath, Modules. Under the new items

  • Phthon fourth. Python standard library (sys and os) Introduction 2010-11-01

    1.sys module (not in the windows debug) import sys def readfile (filename): '''Print a file to the standard output.''' f = file (filename) while True: line = f.readline () if len (line) == 0: break print line, # notice comma f.close () # Script start

  • The os and sys python 2011-05-09

    http://linux.chinaitlab.com/manual/python_chinese/ch14.html backup ------------ #!/usr/bin/python # Filename: backup_ver1.py import os import time # 1. The files and directories to be backed up are specified in a list. source = ['/home/swaroop/byte',

  • Python中使用md5sum检查目录中相同文件代码分享 2013-12-16

    这篇文章主要介绍了Python中使用md5sum检查目录中相同文件代码分享,本文直接给出实现代码,需要的朋友可以参考下 """This module contains code from Think Python by Allen B. Downey http://thinkpython.com Copyright 2012 Allen B. Downey License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html &quo