Python文件的操作2
来源:互联网 发布:2016交通事故数据 编辑:程序博客网 时间:2024/05/23 19:47
#文件的复制、剪切:import shutilshutil.copyfile('hello word.txt', 'hello1.txt')shutil.move('hello1.txt', '..\hello.txt')#move#文件的重命名:import osls = os.listdir('.\\')print '========================'for file in ls: if 'hello word.txt' == file: print file os.rename(file, 'hello2.txt')#delete文件的删除import os.pathif os.path.exists('hello.txt') or os.path.exists('hello2.txt'): os.remove('hello.txt') os.remove('hello2.txt') print 'del'#ini配置文件的读取,写入import ConfigParserconfig = ConfigParser.ConfigParser()config.read('db100.ini')print config.sections()print config.options('config')print config.get('config', 'version')print config.set('config', 'version', '2.3.3')fp = open('db100.ini','w')config.write(fp)fp.close() #目录的创建和删除 import osos.mkdir('11') os.makedirs('1/2/3')os.rmdir('11')os.removedirs('1/2/3')
0 0
- Python文件的操作2
- Python的文件操作
- Python的文件操作
- Python的文件操作
- python的文件操作
- python的文件操作
- Python的文件操作
- python的文件操作
- Python的文件操作
- python的文件操作
- Python-文件的操作
- python 的文件操作
- python的文件操作
- python-文件操作(2)
- Python文件操作2
- 简单的python文件操作。
- python对文件的操作
- Python 文件的读写操作
- SQL Server中利用正则表达式替换日期中的"-|:| "字符串为空
- 设计模式--策略模式
- centos 修改Mac
- ScrollView中嵌套ListView滚动效果冲突问题
- Android微信支付
- Python文件的操作2
- sort函数、max_element和min_element函数
- Go-数组
- Android Studio Flavors详解
- Android系统内置应用更新或升级后被还原的原因
- supervisor 进程管理
- MATLAB BP神经网络用法的总结(试用于初学者)
- C# 发EDM
- vi编译器