当前位置:网站首页>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
边栏推荐
- Stackoverflow 年度报告 2022:开发者最喜爱的数据库是什么?
- DX12引擎开发课程进度-这个课程到底讲到哪里了
- I just purchased a MySQL database and prompted that there are already instances. The console login instance needs to provide a database account. How do I know the database account.
- Hongxiang Yunteng is compatible with dragon lizard operating system, and the product runs stably
- 主数据建设的背景
- DAPP system customization of full chain hash game (scheme design)
- 建立自己的网站(14)
- [cann document express issue 05] let you know what operators are
- What are the problems with traditional IO? Why is zero copy introduced?
- 红象云腾完成与龙蜥操作系统兼容适配,产品运行稳定
猜你喜欢

Leetcode(135)——分发糖果

Bridging mode -- law firm

传统的IO存在什么问题?为什么引入零拷贝的?

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

Set up your own website (14)

《梦华录》“超点”,鹅被骂冤吗?

Agency mode -- Jiangnan leather shoes factory

顺序栈1.0版本

Freshman girls' nonsense programming is popular! Those who understand programming are tied with Q after reading

Image panr
随机推荐
二叉树的基本性质与遍历
How to apply agile development ideas to other work
Simulation lottery and probability statistics experiment of the top 16 Champions League
Apple, Microsoft and Google will no longer fight each other. They will work together to do a big thing this year
"Ningwang" was sold and bought at the same time, and Hillhouse capital has cashed in billions by "selling high and absorbing low"
《梦华录》“超点”,鹅被骂冤吗?
Image panr
DAPP system customization of full chain hash game (scheme design)
Map跟object 的区别
Prototype mode -- clone monster Army
Selenium crawl notes
Leetcode(135)——分发糖果
The first public available pytorch version alphafold2 is reproduced, and Columbia University is open source openfold, with more than 1000 stars
Steps of JMeter performance test
Bytebase加入阿里云PolarDB开源数据库社区
Sequential stack traversal binary tree
Ribbon source code analysis @loadbalanced and loadbalancerclient
Popupwindow touch event transparent transmission scheme
主数据建设的背景
The largest DPU manufacturer in history (Part 1)