0
How read method will behave in files encoded in utf, since some characters in utf have 2 bytes?
1 Réponse
0
I tried with filename.txt containing:
abcdefghijklmnop你好Henrique
and this code:
file = open("filename.txt", "r")
print("reading 16")
print(file.read(16))
print("reading 2")
print(file.read(2))
print("reading 5")
print(file.read(5))
print("reading remainder")
print(file.read())
file.close()
I got these results:
christopher@water:~/py3eg$ python3 readfiles.py
reading 16
abcdefghijklmnop
reading 2
你好
reading 5
Henri
reading remainder
que