Yes, it's valid. Check the docs on the open()
function:
The available modes are:
Character Meaning
'r' open for reading (default)
'w' open for writing, truncating the file first
'x' open for exclusive creation, failing if the file already exists
'a' open for writing, appending to the end of the file if it exists
'b' binary mode
't' text mode (default)
'+' open a disk file for updating (reading and writing)
'U' universal newlines mode (deprecated)
In text mode (the default, or when 't'
is included in the mode
argument), the contents of the file are returned as str
, the bytes
having been first decoded using a platform-dependent encoding or using
the specified encoding if given.