How can I replace Unicode characters with Turkish characters in a text file with Python
<p>I am working on Twitter. I got data from Twitter with Stream API and the result of app is JSON file. I wrote tweets data in a text file and now I see Unicode characters instead of Turkish characters. I don't want to do find/replace in Notepad++ by hand. Is there any automatic option to replace characters by opening txt file, reading all data in file and changing Unicode characters with Turkish characters by Python?</p>

<p>Here are Unicode characters and Turkish characters which I want to replace.</p>

<ul>
<li>ğ - \u011f</li>
<li>Ğ - \u011e</li>
<li>ı - \u0131</li>
<li>İ - \u0130</li>
<li>ö - \u00f6</li>
<li>Ö - \u00d6</li>
<li>ü - \u00fc</li>
<li>Ü - \u00dc</li>
<li>ş - \u015f</li>
<li>Ş - \u015e</li>
<li>ç - \u00e7</li>
<li>Ç - \u00c7</li>
</ul>

<p>I tried two different type</p>

<pre><code>#!/usr/bin/env python

# -*- coding: utf-8 -*- 

import re

dosya = open('veri.txt', 'r')

for line in dosya:
    match = re.search(line, "\u011f")
    if (match):
        replace("\u011f", "ğ")

dosya.close()
</code></pre>

<p>and:</p>

<pre><code>#!/usr/bin/env python

# -*- coding: utf-8 -*- 

f1 = open('veri.txt', 'r')
f2 = open('veri2.txt', 'w')

for line in f1:
    f2.write=(line.replace('\u011f', 'ğ')) 
    f2.write=(line.replace('\u011e', 'Ğ'))
    f2.write=(line.replace('\u0131', 'ı'))
    f2.write=(line.replace('\u0130', 'İ'))
    f2.write=(line.replace('\u00f6', 'ö'))
    f2.write=(line.replace('\u00d6', 'Ö'))
    f2.write=(line.replace('\u00fc', 'ü'))
    f2.write=(line.replace('\u00dc', 'Ü'))
    f2.write=(line.replace('\u015f', 'ş'))
    f2.write=(line.replace('\u015e', 'Ş'))
    f2.write=(line.replace('\u00e7', 'ç'))
    f2.write=(line.replace('\u00c7', 'Ç'))

f1.close()
f2.close()
</code></pre>

<p>Both of these didn't work. 
How can I make it work?</p>