Accademia:Conv to utf8.py
- !/usr/bin/env python3
def all_to_utf8(inputfile, inputenc):
"""Convert the text file encoding to utf8.""" iso = open(inputfile, 'r', inputenc) utf = open('testo_utf', 'w') # to be modified for line in iso: utf.write(line) iso.close() utf.close() #TODO
def main():
all_to_utf8('testo', 'latin_1') f = open('testo_utf') print(f.read()) f.close()
if __name__ == '__main__':
main()
- ./il_mio_script -e encoding nomefile
- attenzione: modifica la codifica DI QUEL FILE
- suggerimento: uso di file temporaneo...