Convert Unicode to ANSI or UTF8 in python
Question: I am using Python 2.7.8 and I have a script which does parsing:

    
    
    def parse():
        with open('myfile.txt') as f:
    .
    .
    .
    Print l
    

myfile.txt has a UNICODE coding. How can I add a code to this script so that
it reads the myfile.txt as ANSI for example?


Answer: using io solved my problem:

    
    
    import io    
    def parse()
        with io.open(path,'r',encoding='utf_16') as f:
    .....
    

solved my problem.

