ehmatthes / pcc_3e

Online resources for Python Crash Course, 3rd edition, from No Starch Press.
1.11k stars 445 forks source link

pathlib.Path read_text() #4

Closed umarhunter closed 1 year ago

umarhunter commented 1 year ago

In chapter 16 the book used path.read_text() (in 'eq_world_map.py'), when the read_text function now requires a parameter to be passed (encoding=None). In this case, it should be encoding='utf-8' (on my environment). If you don't pass an encoding type, you get this error message: UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 32096: character maps to <undefined>

ehmatthes commented 1 year ago

Yes, that argument is needed on systems where utf-8 is not the default encoding. In the third printing of the book, I added that argument in for all occurrences of read_text() in Chapter 16. Thank you for bringing this up.