Difference between a text file in r and rb mode
what’s the Difference between r and rb in fopen
0. EOL (end-of-line)
The difference is mainly in the treatment of EOL. For different operating systems,
Unix: \n
Mac: \r
Windows: \r\n
For the Python language, the query is performed using the following statement:
>> import os
>> os.linesep
'\r\n'
1. Different operating systems
For Windows systems, having b
(rb
, wb
, r+b
) means to open files in binary form. Python on Windows handles text files differently than binary files,
2. Python 2 vs Python 3
For Python 3 environments:
r
: Python returns STR
rb
: binary mode, read()
returns 0 bytes
1
Read More:
- [HTML] Python extracts HTML text to TXT
- How to convert audio to subtitle (text) with Python?
- Python implements inserting content in the specified position of text
- python reads csv file is an error _csv.Error: iterator should return strings, not bytes (did you open the file in text)
- Python json.dumps () json.dump The difference between ()
- Python uses cxfree to package script files into executable programs
- python cx_Oracle.DatabaseError: Error while trying to retrieve text for error ORA-01804
- [Mac OS] ASUS z97-k r2.0 + gtx960 + clover v2.4k r4098 install Sierra 10.12.5 problems and Solutions
- Ida batch processes virus share samples to obtain ASM files and bytes files
- The too many open files solution appears in stream classes such as files.list
- Springboot project: error parsing HTTP request header note: further occurrences of HTTP request parsing
- C#: Analysis of the difference between write() and writeline()
- Difference between vs code user and system version
- Can’t find Python executable “D:\python3\python.exe”, you can set the PYTHON env variable.
- The difference of. Pt,. PTH,. Pkl and the way to save the model
- The difference and usage of insmod and modprobe
- JavaScript summary: the difference between typeof and instanceof, and Object.prototype.toString() method
- The difference between problem and observables
- The difference between “?” and “?:” introduced by php7
- The difference between classnotfoundexception and NoClassDefFoundError