Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente | Prochaine révision Les deux révisions suivantes | ||
scripts-python [2017/07/25 19:02] |
scripts-python [2017/07/25 19:04] 127.0.0.1 modification externe |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ====== Scripts Python ====== | ||
+ | ===== Corriger l' | ||
+ | [[https:// | ||
+ | |||
+ | |||
+ | Installer pip et ftfy sous ubuntu | ||
+ | <code bash> | ||
+ | apt install python3-pip | ||
+ | pip3 install ftfy | ||
+ | </ | ||
+ | |||
+ | Corriger l' | ||
+ | <code python> | ||
+ | # | ||
+ | # coding: utf-8 | ||
+ | |||
+ | import ftfy | ||
+ | |||
+ | # Set input_file | ||
+ | input_file = open(' | ||
+ | # Set output file | ||
+ | output_file = open (' | ||
+ | |||
+ | # Create fixed output stream | ||
+ | stream = ftfy.fix_file( | ||
+ | input_file, | ||
+ | encoding=None, | ||
+ | fix_entities=' | ||
+ | remove_terminal_escapes=False, | ||
+ | fix_encoding=True, | ||
+ | fix_latin_ligatures=False, | ||
+ | fix_character_width=False, | ||
+ | uncurl_quotes=False, | ||
+ | fix_line_breaks=False, | ||
+ | fix_surrogates=False, | ||
+ | remove_control_chars=False, | ||
+ | remove_bom=False, | ||
+ | normalization=' | ||
+ | ) | ||
+ | |||
+ | # Save stream to output file | ||
+ | stream_iterator = iter(stream) | ||
+ | while stream_iterator: | ||
+ | try: | ||
+ | line = next(stream_iterator) | ||
+ | output_file.write(line) | ||
+ | except StopIteration: | ||
+ | break | ||
+ | </ |