import os size=0 filename='输入你的文件夹绝对路径' for g in os.walk(filename): path, dir_list, name_list=g for name in name_list: abs_path=os.path.join(path,name ...
分类:
编程语言 时间:
2020-07-05 21:10:49
阅读次数:
56
1.项目准备 1.在settings.py中 STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') # STATICFILES_DIRS = ( # os.path.join(BASE_DIR, 'static' ...
分类:
其他好文 时间:
2020-07-03 17:22:59
阅读次数:
79
安装xlrd # windows 安装 pip install xlrd # mac 安装 pip3 install xlrd 使用xlrd 1.导入xlrd import xlrd 2.打开excel # 添加文件路径 excel_path = os.path.join(os.path.dirna ...
分类:
其他好文 时间:
2020-07-03 10:33:38
阅读次数:
85
一 相关知识 1 exists命令: 功能:基于一个字符串里面的变量文件名来判断文件是否存在,如果存在,返回 True ;不存在,返回 False 。 注意:在脚本中使用该命令需要导入:from os.path import exists 2 cat命令 功能:用于连接文件并打印到标准输出设备上。 ...
分类:
其他好文 时间:
2020-07-03 09:11:31
阅读次数:
64
1、验证码生成代码 import random import string import os.path from io import BytesIO from PIL import Image from PIL import ImageFilter from PIL.ImageDraw impor ...
分类:
其他好文 时间:
2020-06-30 00:54:25
阅读次数:
89
import os pwd = os.getcwd() print("当前目录: " + pwd) father_path_method1 = os.path.dirname(pwd) print("当前目录的父目录_方式一: " + father_path_method1) separator = ...
分类:
其他好文 时间:
2020-06-29 11:28:09
阅读次数:
136
import time import os import getpass # 时间戳 times = time.strftime("%Y%m%d%H%M%S") # 项目的绝对路径 BASE_PATH = '/'.join(os.path.abspath(__file__).split("/")[: ...
分类:
其他好文 时间:
2020-06-27 13:23:15
阅读次数:
52
Django日志配置 django中的log需要在settings.py中配置 import time LOGGING_DIR = os.path.join(BASE_DIR, "logs") # LOGGING_DIR 日志文件存放目录 if not os.path.exists(LOGGING_ ...
分类:
其他好文 时间:
2020-06-26 20:21:31
阅读次数:
55
项目健壮性提高 path参数化 import os # 获取项目所在的绝对路径 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # 用例模块所在的目录路径 CASE_DIR = os.path.join(B ...
分类:
其他好文 时间:
2020-06-26 12:42:27
阅读次数:
61
#1.路径相关 ##1.1 获取目录 import os Path = os.getcwd() print('本文件所在目录:'+Path) print('所在目录的上级目录'+os.path.dirname(Path)) ##1.2 获取当前系统下的路径间隔符(用于路径拼接) os.sep imp ...
分类:
编程语言 时间:
2020-06-23 21:46:03
阅读次数:
70