当前位置:网站首页>3. File operation 3-with
3. File operation 3-with
2022-07-06 08:17:00 【wwanxinghao】
1、with: Benefits: no need to close files manually (f.close())
The following is a simple operation of reading files
with open(' New files .txt',mode='r' ,encoding='utf-8') as f:
for i in f:
print(i.strip())
2、 The following validation with No use close()
3、 Pattern mode='rb', Yes Read non text , Namely , Audio , video , Picture these , These are not stored in strings , It is stored in bytes ;mode='wb', Write audio , video , Picture these data ( They are stored in bytes )
The following example is , Will a mp4 The operation of assigning a copy to a file
边栏推荐
猜你喜欢
Esrally domestic installation and use pit avoidance Guide - the latest in the whole network
The State Economic Information Center "APEC industry +" Western Silicon Valley will invest 2trillion yuan in Chengdu Chongqing economic circle, which will surpass the observation of Shanghai | stable
[cloud native] teach you how to build ferry open source work order system
From monomer structure to microservice architecture, introduction to microservices
[untitled]
Summary of phased use of sonic one-stop open source distributed cluster cloud real machine test platform
Interview Reply of Zhuhai Jinshan
wincc7.5下载安装教程(Win10系统)
Easy to use tcp-udp_ Debug tool download and use
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
随机推荐
24. Query table data (basic)
The State Economic Information Center "APEC industry +" Western Silicon Valley will invest 2trillion yuan in Chengdu Chongqing economic circle, which will surpass the observation of Shanghai | stable
Leetcode question brushing record | 203_ Remove linked list elements
【云原生】手把手教你搭建ferry开源工单系统
数据治理:微服务架构下的数据治理
Data governance: 3 characteristics, 4 transcendence and 3 28 principles of master data
Golang DNS write casually
从 SQL 文件迁移数据到 TiDB
JS select all and tab bar switching, simple comments
Image fusion -- challenges, opportunities and Countermeasures
Use br to back up tidb cluster data to S3 compatible storage
Migrate data from a tidb cluster to another tidb cluster
[untitled]
Use dumping to back up tidb cluster data to S3 compatible storage
Machine learning - decision tree
Understanding of law of large numbers and central limit theorem
Wincc7.5 download and installation tutorial (win10 system)
File upload of DVWA range
Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower