What is the difference between rb and r+b modes in file objects

前端 未结 4 1237
借酒劲吻你
借酒劲吻你 2020-12-04 14:27

I am using pickle module in Python and trying different file IO modes:

# works on windows.. \"rb\"
with open(pickle_f, \'rb\') as fhand:
        obj = pickle         


        
4条回答
  •  广开言路
    2020-12-04 15:03

    My understanding is that adding r+ opens for both read and write (just like w+, though as pointed out in the comment, will truncate the file). The b just opens it in binary mode, which is supposed to be less aware of things like line separators (at least in C++).

提交回复
热议问题