zoukankan      html  css  js  c++  java
  • Python-open()的模式

    open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)    

    The available modes are:

    ========= ===============================================================
    Character Meaning
    --------- ---------------------------------------------------------------
    'r' open for reading (default)                                                          只读 【open()函数的默认模式】
    'w' open for writing, truncating the file first                                    首先清空文件,然后写
    'x' create a new file and open it for writing                                    新建一个文件并且可以写入
    '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)                    打开文件进行读写
    ========= ===============================================================

    补充:

    r+:可读可写,若文件不存在,报错

    w+: 可读可写,若文件不存在,创建

    版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。

    https://blog.csdn.net/py_tester/article/details/78347602

  • 相关阅读:
    LINQ/EF/Lambda 比较字符串日期时间大小
    WinForm RDLC SubReport Step by step
    centos7安装7-zip
    centos修改命令提示符颜色
    更换官方zabbix.repo为阿里云镜像
    利用shell脚本清理nginx日志
    docker
    centos 建立静态 IP 与 IP 地址丢失的解决办法
    构建lnmp高可用架构
    keepalived高可用
  • 原文地址:https://www.cnblogs.com/ohlala/p/11389220.html
Copyright © 2011-2022 走看看