当前位置:网站首页>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
边栏推荐
- 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"
- What does virtualization mean? What technologies are included? What is the difference with private cloud?
- I feel that I am bald again when I help my children with their homework. I feel pity for my parents all over the world
- 二叉树的基本性质与遍历
- Hongxiang Yunteng is compatible with dragon lizard operating system, and the product runs stably
- How to apply agile development ideas to other work
- Jd.com: how does redis implement inventory deduction? How to prevent oversold?
- 伯克利、MIT、剑桥、DeepMind等业内大佬线上讲座:迈向安全可靠可控的AI
- Stackoverflow 年度报告 2022:开发者最喜爱的数据库是什么?
- 传统的IO存在什么问题?为什么引入零拷贝的?
猜你喜欢

Apple doesn't need money, but it has no confidence in its content

Vant component used in wechat applet

得物多活架构设计之路由服务设计

Prototype mode -- clone monster Army
![Use the transparent [x] cross button image in the dialog](/img/0c/2be7bc7f20b581a2cc745d9cabe9ff.jpg)
Use the transparent [x] cross button image in the dialog

宅男救不了元宇宙

I feel that I am bald again when I help my children with their homework. I feel pity for my parents all over the world

When querying the database with Gorm, reflect: reflect flag. mustBeAssignable using unaddressable value

Grating diffraction

Freshman girls' nonsense programming is popular! Those who understand programming are tied with Q after reading
随机推荐
传统的IO存在什么问题?为什么引入零拷贝的?
maptalks:数据归一化处理与分层设色图层加载
宅男救不了元宇宙
Map跟object 的区别
用手机摄像头就能捕捉指纹?!准确度堪比签字画押,专家:你们在加剧歧视
Basic concepts and definitions of Graphs
opds sql组件能不能将流程参数通过上下文传给下一个组件
实现基于Socket自定义的redis简单客户端
基于SSM的物料管理系统(源码+文档+数据库)
The AI for emotion recognition was "harbouring evil intentions", and Microsoft decided to block it!
Wechat applet custom tabbar
[suggested collection] time series prediction application and paper summary
Set up your own website (14)
CVPR 2022 remembers Sun Jian! Tongji and Ali won the best student thesis award, and hekaiming was shortlisted
Predicate
伯克利、MIT、劍橋、DeepMind等業內大佬線上講座:邁向安全可靠可控的AI
Implement the redis simple client customized based on socket
“拯救”直播带货,一个董宇辉还不够
The four stages of cloud computing development have finally been clarified
Leetcode(135)——分发糖果