gpt4 book ai didi

python - 打开 "U"模式的非弃用版本是什么

转载 作者:行者123 更新时间:2023-11-28 16:57:45 26 4
gpt4 key购买 nike

我正在尝试使用 python 读取文本文件:

with open("Keys.txt","rU") as csvfile:

但是这会产生折旧警告。

DeprecationWarning: 'U' mode is deprecated

此文本/csv 文件访问模式的非弃用版本是什么。

最佳答案

这是现在的默认行为,因此您可以简单地忽略它:

with open("Keys.txt", "r") as csvfile:

来自open() documentation :

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.

顺便说一句,它在 Python 3.11 中被删除了。

另请参阅:Why is universal newlines mode deprecated in Python? - Software Engineering Stack Exchange

关于python - 打开 "U"模式的非弃用版本是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56791545/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com