上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 36 下一页
摘要: os.path.getsize() 返回文件的字节数,如果为 0,则代表空。 import os if os.path.getsize('test.txt') == 0: print('这是空文件') 阅读全文
posted @ 2022-06-09 00:17 lucky_tomato 阅读(1878) 评论(0) 推荐(0) 编辑
摘要: import sys def line_file_test(): print(sys._getframe().f_lineno) # 获取当前行号(行数) line_file_test() 阅读全文
posted @ 2022-06-09 00:14 lucky_tomato 阅读(1309) 评论(0) 推荐(0) 编辑
摘要: Python的collections模块中namedtuple结构使用示例 # 命名元组,使得元组可像列表一样使用key访问(同时可以使用索引访问) from collections import namedtuple # test_name任意起的名字 Point = namedtuple('te 阅读全文
posted @ 2022-06-09 00:05 lucky_tomato 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 前言:在新的工作环境中看到自定义的iptables链,还是补一下这块知识,自定义链是为了将iptables规则进行分类管理,能够根据业务或服务设置规则,更有效去管理防火墙规则 当iptables规则特别多时,我们需要具备模块化思想,需要将不同目的iptables规则进行归类。将同一类型的iptabl 阅读全文
posted @ 2022-06-03 23:25 lucky_tomato 阅读(838) 评论(1) 推荐(0) 编辑
摘要: top 命令 %us:表示用户空间程序的cpu使用率(没有通过nice调度) %sy:表示系统空间的cpu使用率,主要是内核程序。 %ni:表示用户空间且通过nice调度过的程序的cpu使用率。 %id:空闲cpu %wa:cpu运行时在等待io的时间 %hi:cpu处理硬中断的数量 %si:cpu 阅读全文
posted @ 2022-05-29 14:09 lucky_tomato 阅读(1361) 评论(0) 推荐(0) 编辑
摘要: 1、centos安装dig命令 yum -y install bind-utils 2、简单使用 dig www.boyblue.xyz ; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.9 <<>> www.boyblue.xyz ;; global o 阅读全文
posted @ 2022-05-29 12:06 lucky_tomato 阅读(173) 评论(0) 推荐(0) 编辑
摘要: Branch 'master' set up to track remote branch 'master' from 'origin' git上传仓库时报错 解决方法共两步 1、移除 git remote rm origin 2、再次连接 git remote add origin '仓库地址' 阅读全文
posted @ 2022-05-29 12:01 lucky_tomato 阅读(1463) 评论(0) 推荐(0) 编辑
摘要: from collections import Counter n = ['a','b','a','c','d','a'] # 统计list中每个元素出现的个数 eleCounts = Counter(n) # most_common()返回出现次数排名前n个的元素,不输入时默认按照出现次数对所有数 阅读全文
posted @ 2022-05-29 11:55 lucky_tomato 阅读(354) 评论(0) 推荐(0) 编辑
摘要: def max_list(lt): temp = 0 for i in lt: if lt.count(i) > temp: max_ele = i temp = lt.count(i) return "重复次数最多元素为%s,重复次数为%d次" % (max_ele, temp) n = ['a' 阅读全文
posted @ 2022-05-29 11:50 lucky_tomato 阅读(1123) 评论(0) 推荐(0) 编辑
摘要: 获取内存信息 使用psutil获取物理内存和交换内存信息,分别使用: >>> psutil.virtual_memory() svmem(total=8589934592, available=2866520064, percent=66.6, used=7201386496, free=21617 阅读全文
posted @ 2022-05-29 11:32 lucky_tomato 阅读(640) 评论(0) 推荐(0) 编辑
上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 36 下一页