[Tutor] characters in python

Gigs_ gigs at hi.t-com.hr
Wed Oct 18 23:11:41 CEST 2006


here is the code:
def changer():
"""Changer from Serbian to Croatian for this letters: æ, è, ð in ć, č, đ
"""
whatfile = raw_input('Enter location of your file: ')

# open and read file
ofile = open(whatfile, 'r')
S = ofile.read()
ofile.close()

# search file and replace æ, è in ć, č
for i in S:
S = S.replace('æ', 'ć')
S = S.replace('è', 'č')
S = S.replace('ð', 'đ')

# open and write to file
infile = open(whatfile, 'w')
infile.write(S)
infile.close()


I attached file too.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: literalschanger.rar
Type: application/octet-stream
Size: 431 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20061018/d5d22dd8/attachment.obj 


More information about the Tutor mailing list