# 深度遍历打印一个文件夹def print_all_dir(dir): # 判断dir是文件夹 if os.path.isdir(dir): # 如果是文件夹,先打印该文件夹 print(dir) # 再遍历 for next_dir in os.listdir(dir): # 递归调用,针对该文 ...
分类:
编程语言 时间:
2020-02-22 09:43:14
阅读次数:
86
1.新建templates目录 2.在settings里注册 注册的方式: 先找到TEMPLATES的列表,再在该列表中添加 'DIRS': [os.path.join(BASE_DIR, 'templates')] ...
分类:
其他好文 时间:
2020-02-20 15:01:31
阅读次数:
58
os.listdir(dirname):列出dirname下的目录和文件 os.getcwd():获得当前工作目录 os.chdir(dirname):改变工作目录到dirname os.path.realpath(path):返回path的真实路径 os.getcwd:得到当前工作目录,即当前py ...
分类:
编程语言 时间:
2020-02-18 09:48:52
阅读次数:
78
用以下代码做实验 import time import cv2 as cv import glob import argparse import sys import numpy as np import os.path from collections import deque from skle ...
分类:
其他好文 时间:
2020-02-17 16:14:35
阅读次数:
407
1.import os,sys Based_dir=os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(Based_dir) 2.import os os.makedirs(dirname1/dirn ...
分类:
编程语言 时间:
2020-02-12 21:53:30
阅读次数:
71
今天学习了python爬虫的简单操作。 1.学会创建文件夹和创建文件: 1 import os 2 3 def mkdir(path): 4 if os.path.exists(path):###判断是文件夹否存在,否则有可能会报错 5 print("The path has already exi ...
分类:
其他好文 时间:
2020-02-09 14:57:56
阅读次数:
108
os.path 1 #返回标准化的绝对路径,基本等同于normpath() 2 os.path.abspath(path) 3 4 #返回文件名 5 os.path.basename(path) 6 7 #返回目录名 8 os.path.dirname(path) ViCode ...
分类:
编程语言 时间:
2020-02-04 23:21:49
阅读次数:
89
1. os.path.join()os.path.join()函数用于路径拼接文件路径。 os.path.join()函数中可以传入多个路径:会从第一个以”/”开头的参数开始拼接,之前的参数全部丢弃。以上一种情况为先。在上一种情况确保情况下,若出现”./”开头的参数,会从”./”开头的参数的上一个参 ...
分类:
其他好文 时间:
2020-02-04 00:40:23
阅读次数:
80
for file in os.listdir('yolov3_tiny_car_det/output'): fsize = os.path.getsize(f'yolov3_tiny_car_det/output/{file}') if (fsize<40000): os.remove(f'yolo ...
分类:
编程语言 时间:
2020-02-03 19:07:35
阅读次数:
90
import osdef copy(path1, path2): filename = os.path.basename(path1) if os.path.isdir(path2) and os.path.isfile(path1): path2 = os.path.join(path2, fil ...
分类:
其他好文 时间:
2020-02-03 13:46:45
阅读次数:
73