Created
December 19, 2019 19:42
-
-
Save miracleyoo/1e1554f3ee062b7973624a495b3d3bf1 to your computer and use it in GitHub Desktop.
[Read Write with Right Encoding] #python #file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import chardet | |
with open(input_path, 'rb') as f: | |
s = f.read() | |
chatest = chardet.detect(s) | |
# print(chatest) | |
with open(input_path,"r",encoding=chatest["encoding"]) as f: | |
lines = f.read() | |
with open(output_path, "w+", encoding=chatest["encoding"]) as fw: | |
fw.write(lines) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment