python - python文件操作模块open和file的区别。

标签 python

我正在用 python 进行文件操作,我发现了两个模块, “打开”和"file"这两个文件操作模块有什么区别 在功能方面我发现两者相同。

谢谢。

最佳答案

Python 2.x 文档 says it all :

When opening a file, it’s preferable to use open() instead of invoking this constructor [file()] directly. file is more suited to type testing (for example, writing isinstance(f, file)).

在 Python 3.x 中,file 不再可用。

关于python - python文件操作模块open和file的区别。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6859499/

相关文章:

python - 我正在寻找 python 中 FDIST 的等效函数

Python:无法 imoport keras,导入错误:没有名为 tensorflow 的模块

python - 弱 Debian SSH key Python 脚本 Cryptic auth.log

python - 使用 Python 在 Google 中搜索

python - 无法嗅探以太网类型 0x0102 自定义数据包

python - 如何从 Pandas 中的两列形成元组列

python - 插入表时处理 SQLAlchemy 中的触发器

再次使用 python unbound 方法

python - 基于列插值加入 Pandas

python - Matplotlib:如何绘制两个直方图的差异?