Python测试开发预习课7月2日

    技术2026-06-09  11

    1、 文件操作:

    固定流程: 1)打开文件 open with open 2) 操作 读 写 追加 3)关闭 读文件并且打印文件内容:

    fp=open("e:\\a.txt","r",encoding="utf-8") content = fp.read() fp.close() Print(content)

    >>> fp=open("e:\\a.txt","r",encoding="gbk") >>> content=fp.read() >>> fp.close <built-in method close of _io.TextIOWrapper object at 0x00000286A7DFD7E0> >>> fp.close() >>> content '#encoding="gbk"\n123\n234' >>> fp=open("e:\\a.txt","r") >>> content=fp.read() >>> fp.close() >>> content '
    Processed: 0.019, SQL: 9