Answers for "Not getting spanish characters python"

1

Not getting spanish characters python

Make sure your using utf-8 encoding

# for reading files
file = open("test.txt", "r", encoding="utf-8")

# for strings
TestText = "Test - āĀēĒčČ..šŠūŪžŽ" # this not UTF-8...it is a Unicode string in Python 3.X.
TestText2 = TestText.encode('utf8') # this is a UTF-8-encoded byte string.
Posted by: Guest on January-29-2022

Python Answers by Framework

Browse Popular Code Answers by Language