3

I have a file contains string "1234" and I save it with "utf-8". Then I open it with python3:

with open('test2.txt', 'r', encoding="utf-8") as f:
    for line in f.readlines():
        line = line.strip()
        print("len: ", len(line))
        print(line[0])
        print(line[1])

I got this output:

len:  5

1

If I save it with "ANSI", there will be no extra space. I have tried created it with UltraEdit and the space remains the same.

How can I remove the space?

akhilsp
  • 1,063
  • 2
  • 13
  • 26
Sikai Yao
  • 227
  • 3
  • 10

0 Answers0