What is the non deprecated version of open "U" mode
It's the default behaviour now, so you can simply omit it:
with open("Keys.txt", "r") as csvfile:
More info
There is an additional mode character permitted,
'U'
, which no longer has any effect, and is considered deprecated. It previously enabled universal newlines in text mode, which became the default behaviour in Python 3.0. Refer to the documentation of the newline parameter for further details.
Source: open()
- Python 3.7.4 documentation
The
open()
function in the Python 3 library has anewline
argument. Setting it toNone
enables universal newlines. This is the accepted way to do it, rendering themode='U'
argument redundant.Use
newline=None
to enable universal newlines mode (this is the default).
Source: Robert Harvey's answer on "Why is universal newlines mode deprecated in Python?" on Software Engineering