[Python] Unsure of the behavior for opening a file with mode "wrb"

Discussão em 'Python' iniciado por Stack, Março 5, 2025.

  1. Stack

    Stack Membro Participativo

    I have a socket that I am sending data to through a file created using the makefile method of a socket. However, the mode of the file created using makefile is 'wrb'.

    I understand that 'w' = write, 'r' = read, and 'b' = binary. I also understand that you can combine them in a number of different ways, see Confused by python file mode "w+", which contains a list of possible combinations. However, I've never seen 'w' and 'r' together.

    What is their behavior when together? For example, 'r+' allows reading and writing, and 'w+' does the same, except that it truncates the file beforehand. But what does 'wr' do?

    Continue reading...

Compartilhe esta Página