#!/usr/bin/python # -*- coding: utf-8 -*- diff_words = [] #Créez un dictionnaire permutations = { 'ph' : 'f' , 'qu' : 'kh' , 'y' : 'i' , 't' : 'th' , 'ê' : 'ai' , 'ss' : 'ç' , } #Ouvrir un texte comme matériau brut #Le séparer en lignes #le séparer en mots with open("diff.txt", "r", encoding="ISO-8859-1") as source: for line in source: words = line.split(" ") for word in words: for key, value in permutations.items(): if key in word: word = word.replace(key, value) diff_words.append(word) with open("diff_permute.txt", "w") as destination: destination.write(' '.join(diff_words))