Unix, Linux, JBoss, Websphere, Ant, Python, Oracle DB, Arduino, Raspberry Pi.
30 Nisan 2019 Salı
18 Mart 2019 Pazartesi
Python2 - Replace Turkish characters with ascii look-alikes
#!/usr/bin/python -tt
# -*- coding: utf-8 -*-
import codecs
import sys
from base64 import b64encode#reload()
#sys.setdefaultencoding("utf-8")
UTF8Writer = codecs.getwriter('utf8')
sys.stdout = UTF8Writer(sys.stdout)
def TRreplacer(mmm):
my_dict = dict({u'ğ':"g", u'ş':"s", u'ç':"c", u'ü':"u", u'ı':"i", u'ö':"o", u'Ö':"O", u'Ğ':"G", u'Ş':"S", u'Ç':"C", u'Ü':"U", u'İ':"I"})
for items in my_dict:
mmm=mmm.replace(items,my_dict[items])
return mmm
print TRreplacer(u'YİĞİT ÖZEN')
# -*- coding: utf-8 -*-
import codecs
import sys
from base64 import b64encode#reload()
#sys.setdefaultencoding("utf-8")
UTF8Writer = codecs.getwriter('utf8')
sys.stdout = UTF8Writer(sys.stdout)
def TRreplacer(mmm):
my_dict = dict({u'ğ':"g", u'ş':"s", u'ç':"c", u'ü':"u", u'ı':"i", u'ö':"o", u'Ö':"O", u'Ğ':"G", u'Ş':"S", u'Ç':"C", u'Ü':"U", u'İ':"I"})
for items in my_dict:
mmm=mmm.replace(items,my_dict[items])
return mmm
print TRreplacer(u'YİĞİT ÖZEN')
Kaydol:
Kayıtlar (Atom)