Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Python by (16.4k points)

In python, I'm using pickle module & also trying different file Input-Output modes:

# works on windows.. "rb"

with open(pickle_f, 'rb') as fhand:

        obj = pickle.load(fhand)

# works on linux.. "r"

with open(pickle_f, 'r') as fhand:

        obj = pickle.load(fhand)

# works on both "r+b"

with open(pickle_f, 'r+b') as fhand:

        obj = pickle.load(fhand)

I never read about "r+b" mode anyplace, however discovered referencing about it in the documentation. 

I am getting EOFError on Linux on the off chance that I use "rb" mode and on Windows if "r" is utilized. I just gave "r+b" mode a shot and it's chipping away at both. 

What's "r+b" mode? What's the contrast between "rb" and "r+b"? For what reason accomplishes it work when the others don't?

1 Answer

0 votes
by (26.4k points)

For reading and writing mode, we will use r+.

b is for binary

To open the binary file in write or read mode, we will be using r+b mode.

Click on this link for more information.

Want to know details about python? Come and join: python training course

Related questions

0 votes
1 answer
+2 votes
3 answers

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...