当前位置:网站首页>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
边栏推荐
- 宅男救不了元宇宙
- What will you do if you have been ignored by your leaders at work?
- Two fellow countrymen from Hunan have jointly launched a 10 billion yuan IPO
- Interpreter mode -- formulas for dating
- 物聯網?快來看 Arduino 上雲啦
- IDEA Dashboard
- Hosting service and SASE, enjoy the integration of network and security | phase I review
- 得物多活架构设计之路由服务设计
- Compressed list of redis data structures
- 顺序栈1.0版本
猜你喜欢

Basic concepts and definitions of Graphs

宅男救不了元宇宙

顺序表的基本操作

顺序栈1.0版本

对“宁王”边卖边买,高瓴资本“高抛低吸”已套现数十亿

What does virtualization mean? What technologies are included? What is the difference with private cloud?

伯克利、MIT、剑桥、DeepMind等业内大佬线上讲座:迈向安全可靠可控的AI

Wechat applet custom tabbar

云计算发展的 4 个阶段,终于有人讲明白了

年轻人捧红的做饭生意经:博主忙卖课带货,机构月入百万
随机推荐
Leetcode (135) - distribute candy
What will you do if you have been ignored by your leaders at work?
Predicate
Interpreter mode -- formulas for dating
Bridging mode -- law firm
顺序栈遍历二叉树
实现基于Socket自定义的redis简单客户端
16 excellent business process management tools
用手机摄像头就能捕捉指纹?!准确度堪比签字画押,专家:你们在加剧歧视
Memo mode - game archiving
[performance tuning basics] performance tuning strategy
Design of routing service for multi Activity Architecture Design
Combination mode -- stock speculation has been cut into leeks? Come and try this investment strategy!
科创人·味多美CIO胡博:数字化是不流血的革命,正确答案藏在业务的田间地头
图像PANR
With its own cells as raw materials, the first 3D printing ear transplantation was successful! More complex organs can be printed in the future
Camera rental management system based on qt+mysql
Popupwindow touch event transparent transmission scheme
Berkeley, MIT, Cambridge, deepmind et d'autres grandes conférences en ligne: vers une IA sûre, fiable et contrôlable
字节、腾讯也下场,这门「月赚3000万」的生意有多香?