WebLinuxStudy

导航

 

2019年12月5日

摘要: os.access(file, mode)判断文件的访问权限file为文件mode为操作模式,有这么几种:os.F_OK: 检查文件是否存在;os.R_OK: 检查文件是否可读;os.W_OK: 检查文件是否可以写入;os.X_OK: 检查文件是否可以执行; 阅读全文
posted @ 2019-12-05 21:49 WebLinuxStudy 阅读(1245) 评论(0) 推荐(0) 编辑
 
摘要: 1.os.path.exists()既可以判断文件是否存在,又可以判断文件夹是否存在 2.os.path.isfile()判断文件是否存在 3.os.path.isdir()判断文件夹是否存在 阅读全文
posted @ 2019-12-05 21:48 WebLinuxStudy 阅读(2459) 评论(0) 推荐(0) 编辑
 

2019年12月4日

摘要: 调用pymysql.escape_string('向数据库插入的数据') 例如: import pymysql str = 'as"sdf' print(pymysql.escape_string(str)) 阅读全文
posted @ 2019-12-04 08:25 WebLinuxStudy 阅读(825) 评论(0) 推荐(0) 编辑
 

2019年11月29日

摘要: import os filePath = 'D:\12345' # 判断文件夹是否存在,不存在则创建文件夹if not os.path.exists(filePath): os.makedirs(filePath) 阅读全文
posted @ 2019-11-29 14:39 WebLinuxStudy 阅读(2399) 评论(0) 推荐(1) 编辑
 

2019年11月28日

摘要: import os filepaths = []; dirpaths = []; pathName = r'C:\anfei\json\20191128' for root, dirs, files in os.walk(pathName): for file in files: file_path 阅读全文
posted @ 2019-11-28 23:32 WebLinuxStudy 阅读(1804) 评论(0) 推荐(1) 编辑
 
摘要: dict = {}for i in range(1, 6): if i not in dict: dict[i] = [] for j in range(101, 106): dict[i].append(j)print(dict) 阅读全文
posted @ 2019-11-28 23:05 WebLinuxStudy 阅读(6532) 评论(0) 推荐(0) 编辑
 
摘要: 对于非纯字符串组成的列表,需要使用map(str, 列表)转换,纯字符串组成的列表则不需要转换 阅读全文
posted @ 2019-11-28 22:33 WebLinuxStudy 阅读(1086) 评论(0) 推荐(0) 编辑
 
摘要: 1.命令a.硬链接: ln 源文件 链接名 [root@localhost tmp]# ll -i total 118319574 -rw-r--r-- 2 root root 1 Nov 28 18:07 e.txt [root@localhost tmp]# ln e.txt f [root@l 阅读全文
posted @ 2019-11-28 18:03 WebLinuxStudy 阅读(365) 评论(0) 推荐(0) 编辑
 

2019年11月26日

摘要: 1.进程锁:from multiprocessing import Process, Lock def f(l, i): l.acquire() print('hello world', i) l.release() if __name__ == '__main__': lock = Lock() 阅读全文
posted @ 2019-11-26 15:05 WebLinuxStudy 阅读(1583) 评论(0) 推荐(0) 编辑
 

2019年11月12日

摘要: 匿名函数,也叫闭包函数(closures) ,允许临时创建一个没有制定名称的函数。最常用作回调函数(callback)参数的值。 闭包函数也可以作为变量的值来使用。PHP将会自动把此种表达式转换成内置类 Closure 的对象实例。把一个 Closure 对象赋值给一个变量的方式与普通变量赋值的语法 阅读全文
posted @ 2019-11-12 11:37 WebLinuxStudy 阅读(328) 评论(0) 推荐(0) 编辑