On Thu, Apr 7, 2016, at 04:47, Daiyue Weng wrote:
> Hi, when I read a file, the file string contains Mojibake chars at the
> beginning, the code is like,
>
> file_str = open(file_path, 'r', encoding='utf-8').read()
> print(repr(open(file_path, 'r', encoding='utf-8').read())
>
> part of the string
On Thu, Apr 7, 2016 at 6:47 PM, Daiyue Weng wrote:
> Hi, when I read a file, the file string contains Mojibake chars at the
> beginning, the code is like,
>
> file_str = open(file_path, 'r', encoding='utf-8').read()
> print(repr(open(file_path, 'r', encoding='utf-8').read())
>
> part of the string
Daiyue Weng wrote:
> Hi, when I read a file, the file string contains Mojibake chars at the
> beginning, the code is like,
>
> file_str = open(file_path, 'r', encoding='utf-8').read()
> print(repr(open(file_path, 'r', encoding='utf-8').read())
>
> part of the string (been printing) containing Mo
Daiyue Weng writes:
> Hi, when I read a file, the file string contains Mojibake chars at the
> beginning
You are explicitly setting an encoding to read the file; that is good,
since Python should not guess the input encoding.
The reason it's good is because the issue, of knowing the correct tex
Hi, when I read a file, the file string contains Mojibake chars at the
beginning, the code is like,
file_str = open(file_path, 'r', encoding='utf-8').read()
print(repr(open(file_path, 'r', encoding='utf-8').read())
part of the string (been printing) containing Mojibake chars is like,
'锘縶\n "na