(Sep-07-2019, 02:46 AM)karkas Wrote: After opening as 'utf-8' for writing, the file works well with the subsequent converter.Yes,remember
utf-8
out and in,OS and local system can mess up stuff and choice wrong encoding.newFile = open(fileName, 'w+', encoding='utf-8')
Quote:- C:\code would be a path to my code file?No this is where i placed the file,you can choose whatever place you like.
Rember that
python
and pip
should work from any folder same for all OS,for Windows look hereSo a test like this should work no matter which folder on OS you are in.
E:\div_code\click λ python -V Python 3.7.3 E:\div_code\click λ pip -V pip 19.2.3 from c:\python37\lib\site-packages\pip (python 3.7)
Quote:- What does that λ mean?That use cmder a much better shell than cmd/Poweshell.
Quote:- What is the difference between your first and second example? Just the same with different encoding depending on how you save the file?When i use
rb
then i read file in binary(no encoding).With Unicode still need to decode to a encoding.
>>> s = b'<i>[M\xc3\x9aSICA]</i>' >>> s b'<i>[M\xc3\x9aSICA]</i>' >>> type(s) <class 'bytes'> >>> >>> t = s.decode() >>> t '<i>[MÚSICA]</i>' >>> type(t) <class 'str'>