AllenDowney / ThinkPython2

LaTeX source and supporting code for Think Python, 2nd edition, by Allen Downey.
Other
2.49k stars 1.65k forks source link

Markov.py need to change file read encoding to utf8 - among other issues #94

Open TC-Wheel opened 2 years ago

TC-Wheel commented 2 years ago

I'm getting the following error in Markov.py: File "C:\Users\tyson\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 7158: character maps to I fixed it (or broke it more?) by using a context manager and encoding as utf8.

This is now the output: t h a d b e l i n g s o . W o o d y c o m u s t o t s u r c e . H e c a n c e a n t h a r r y w i t g i p p e n i t y . ” B u t f i r f r o o b e i g e n t e t h a t s t o c o u t - - e n j u d d a r