Archive for the ‘Python’ Category

My work with Python

March 5, 2010

How to get the list of word from file ending with specific character:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
//For using Tamil character

try:

f = open(“/home/xxxx/Desktop/test1.txt”,”w”)              //Open a file to write

except IOError:

pass

def fill(str1):

word_list = str1.split()

for word1 in word_list:

lastchar = word1

if lastchar.endswith(‘ல்’):

word2 = word1
f.write(word2)
f.write(\n)

file1 = open(“/home/xxxx/Desktop/read.txt”)                     //Open a file to read
str1 = file1.read()

fill(str1)                                                                                     //Call the function

OutPut:

Advertisements