
文件处理
flesh_coder
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
面试准备,输入输出(c++/python)
C++常用的输入输出cin/cin.getline/cin.get/getline(string)Tab、space结束符。enter是判断输入流结束的表现。不要把他和普通的结束符看成一样的。cin.getline /cin.get都是遇到enter会终止,但不同的是,cin.getline会把缓冲区当中的enter删除掉,不影响下一次的输入。而cin.get不会删除。getline(string):Get line from stream into string (function)原创 2020-06-08 23:12:09 · 659 阅读 · 0 评论 -
文件重命名
两个重命名程序,rename1,直接重命名程序rename2,一个文件夹内有两种不同后缀的文件时,新建一个新文件夹,不同后缀分开重命名比如,有1.txt … 9.txt , 7.jpg… 10.jpg文件,重命名后:000001.txt, 000002.txt, … 000009.txt;000001.jpg, 000002.jpg, 000003.jpg# ---------------...原创 2019-11-29 15:56:40 · 397 阅读 · 0 评论 -
python读文件夹图片,做数据集
程序功能:读取文件夹内图片并输出形状[m,n_H,n_W,n_C]的数组m:图片数量n_H:图片高度n_W:图片宽度n_C:图片维数def read_picture(path,n_C): import os from PIL import Image import numpy as np import matplotlib.pyplot as plt ...原创 2019-08-31 21:41:24 · 6290 阅读 · 7 评论 -
python文件处理:os库与shutil库介绍
os.sep 可以取代操作系统特定的路径分隔符。windows下为 '\\'os.name 字符串指示你正在使用的平台。比如对于Windows,它是'nt',而对于Linux/Unix用户,它是 'posix'os.getcwd() 函数得到当前工作目录,即当前Python脚本工作的目录路径os.getenv() 获取一个环境变量,如果没有返回noneos.pute...转载 2019-09-02 10:26:05 · 240 阅读 · 0 评论 -
python中实现txt文件读写
def read_txt(path,pass_n,model=0): import os import numpy as np #function:读取文件夹内txt文件 #path:str,txt文件所在文件夹 #pass_n:int,从txt文件中第pass_n行开始读文件 #model:int,两个模式,model=0,不按行列顺序存储数据,m...原创 2019-09-02 19:45:49 · 1013 阅读 · 0 评论 -
python新建文件夹
创建路径为path的文件夹(path应该包括新建文件夹名字) def mkdir(path): #path为从程序目录到要创建的目录路径(包含新建文件夹名) #引入模块 import os #去除首尾空格 path=path.strip() #strip方法只要含有该字符就会去除 #去除首尾\符号...原创 2019-09-02 20:04:47 · 8324 阅读 · 0 评论