Python Programs

Python - Files and Regular Expressions

Working with Files

fp = open('temp.txt', 'r')   # opening
content = fp.read()          # reading
fp.close()                   # closing

Regular Expressions

import re
pattern='for'
text='information'
if re.search(pattern, text):
    print('Yes')

Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Home
Subscribe to: Posts (Atom)

Main

  • Sample Programs

Pages

  • Python - Home
  • Python - Database Connectivity
  • Python - Higher Order Functions
  • Python - Files and Regular Expressions
  • Python - Closures
  • Python - Decorators
  • Python - Descriptors
  • Python - Class and Static Methods
  • Python - Abstract Class
  • Python - Context Manager
  • Python - Coroutines
  • Python - doctest
  • Python - unittest
  • Python - nose
  • Python - Pytest
  • Python - NumPy
  • Python - NumPy Arrays
  • Python - NumPy Array Shaping
  • Python - Iterating NumPy Arrays
  • Python - Slicing NumPy Arrays
  • Python - Array Operations
  • Python - List Comparison
3509
Simple theme. Powered by Blogger.