Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (12.7k 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
asked Jun 26, 2019 in Python by Aarav (11.4k points)
0 votes
1 answer
0 votes
1 answer
asked Mar 1 in Python by Rekha (2.2k points)

Browse Categories

...