I found a program online and just modified it a little, but the tamil characters are not printed properly. when i give a compile time input senetence in the pgm itself, it prints the characters properly into the new file. But when i give a file as an input, it does not print it properly. the vowel mathras are printed separately. how do i solve this?
Input : sentence given in the pgm itself
#!usr/bin/python
# -*- coding:UTF-8 -*-
import codecs,os
import tamil.utf8 as utf8
with codecs.open('singl','w',encoding='utf-8') as ff:
letters = utf8.get_letters(u"கூவிளம் என்பது என்ன சீர்")
for letter in letters:
ff.write(unicode(letter))
print unicode(letter)
ff.write('\n')
ff.close()
output: கூ வி ள ம் எ ன் ப து எ ன் ன சீ ர்
Input: From a File
#!usr/bin/python
# -*- coding:UTF-8 -*-
import codecs,os
import tamil.utf8 as utf8
with codecs.open('syll','r',encoding='utf-8') as f:
with codecs.open('singl','w',encoding='utf-8') as ff:
for line in f.read():
letters = utf8.get_letters(line)
for letter in letters:
ff.write(unicode(letter))
print unicode(letter)
ff.write('\n')
ff.close()
f.close()
output: அ ற ு ப த ு க ள ை
根据评论,解决该问题的方法是在行尾删除换行符。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.