当前位置:网站首页>Rename and delete files
Rename and delete files
2022-06-24 20:48:00 【m0_ sixty-two million four hundred and ninety-six thousand nine】
Python Of os Module provides methods to help you perform file processing operations , Such as renaming and deleting files
To use this module , You must import it first , Then you can call various related functions
Rename() Method :
Rename() Method requires two parameters , Current file name and new file name
grammar :
os.rename( route \ Old file name , route \ New file name )
If you do not give the new file name path , After renaming, the file will be placed in the same path as the code file
Example :
The following example will rename an existing file foo.txt
Import os
# Rename file foo.txt To fo.txt
Os.rename(“foo.txt”,”fo.txt”)
Remove() Method
You can use it. remove() Method to delete the file , You need to provide the file name to be deleted as a parameter
grammar :
Os.remove(file_name)
Python modular , It's a python file , With .py ending , Contains python Object definition and python sentence , When you need other code file methods , No need to rewrite the code , You can directly import the code file into the current file , You can use this method directly
When you need to use methods under other modules , You need to import this module into the current module
from.....import......
Python Of from Statement allows you to import a specified part from a module into the current namespace
Is the name of the method that can be used directly
import modular
Import xx Module to current page , When using the method, you need to add the module name
example :import Module name
When using : Module name . Release method (). Call in this format
Time Time module ,sleep() Script pause :
After import , You can use sleep function , Give function pause time . example :sleep(10)
From time import sleep
边栏推荐
- CVPR 2022缅怀孙剑!同济、阿里获最佳学生论文奖,何恺明入围
- JMeter installation plug-in, adding [email protected] -Perfmon metric collector listener steps
- Hongxiang Yunteng is compatible with dragon lizard operating system, and the product runs stably
- The Network Security Review Office launched a network security review on HowNet, saying that it "has a large amount of important data and sensitive information"
- Leetcode(455)——分发饼干
- More than ten years' work experience is recommended at the bottom of the box: how much does it cost to find a job? See here! Brothers and sisters are recommended to collect and pay attention
- Freshman girls' nonsense programming is popular! Those who understand programming are tied with Q after reading
- C langage pour le déminage (version simplifiée)
- Postman assertion
- [cann document express issue 05] let you know what operators are
猜你喜欢

顺序表的基本操作

"Ningwang" was sold and bought at the same time, and Hillhouse capital has cashed in billions by "selling high and absorbing low"

Map跟object 的区别
![Use the transparent [x] cross button image in the dialog](/img/0c/2be7bc7f20b581a2cc745d9cabe9ff.jpg)
Use the transparent [x] cross button image in the dialog

在Dialog中使用透明的【X】叉叉按钮图片

Berkeley, MIT, Cambridge, deepmind and other industry leaders' online lectures: towards safe, reliable and controllable AI

物联网?快来看 Arduino 上云啦

What are the problems with traditional IO? Why is zero copy introduced?

The latest simulated question bank and answers of the eight members (Electrical constructors) of Sichuan architecture in 2022

Agency mode -- Jiangnan leather shoes factory
随机推荐
[cann document express issue 05] let you know what operators are
Learn together and make progress together. Welcome to exchange
顺序栈1.0版本
Grating diffraction
Why do we always "give up halfway"?
Bean lifecycle flowchart
Apple, Microsoft and Google will no longer fight each other. They will work together to do a big thing this year
Smooth live broadcast | analysis of key technologies for live broadcast pain points
[cloud resident co creation] ModelBox draws your own painting across the air
Predicate
Leetcode (455) - distribute cookies
It is said that Tencent officially announced the establishment of "XR" department to bet on yuanuniverse; Former CEO of Google: the United States is about to lose the chip competition. We should let T
微信小程序中使用vant组件
VXLAN 与 MPLS:从数据中心到城域以太网
全上链哈希游戏dapp系统定制(方案设计)
得物多活架构设计之路由服务设计
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
云计算发展的 4 个阶段,终于有人讲明白了
Basic concepts and definitions of Graphs
托管服务与SASE,纵享网络与安全融合 | 一期一会回顾