摘要:
sample_to_row = {row[0]: row for row in lines[1:]} 001、sample_to_row = {row[0]: row for row in lines[1:]} 阅读全文
posted @ 2025-07-16 19:42
小鲨鱼2018
阅读(7)
评论(0)
推荐(0)
摘要:
python中 输出空行行号 [root@PC1 test]# ls a.txt test.py [root@PC1 test]# cat -n a.txt 1 01 02 03 04 2 05 06 07 08 3 4 09 10 11 12 5 6 7 13 14 15 16 8 17 18 1 阅读全文
posted @ 2025-07-16 11:30
小鲨鱼2018
阅读(4)
评论(0)
推荐(0)
摘要:
001、 [root@PC1 test]# ls a.txt test.py [root@PC1 test]# cat a.txt 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 [root@PC1 test]# python 阅读全文
posted @ 2025-07-16 11:22
小鲨鱼2018
阅读(3)
评论(0)
推荐(0)
摘要:
001、 >>> from collections import defaultdict ## 从collections模块中导入defaultdict类 >>> dict1 = {} ## 定义普通字典 >>> dict1["kk"] ## 当索引一个不存在的健 Traceback (most r 阅读全文
posted @ 2025-07-16 10:35
小鲨鱼2018
阅读(34)
评论(0)
推荐(0)
摘要:
01、基本用法 >>> name = "zhang san" >>> age = 30 >>> print(f"his name is {name}, his age is {age}.") ## 格式化输出函数f his name is zhang san, his age is 30. 阅读全文
posted @ 2025-07-16 09:12
小鲨鱼2018
阅读(5)
评论(0)
推荐(0)
摘要:
python 中 跳过表头的实现方式 001、next实现 a、 [root@PC1 test]# ls a.txt test.py [root@PC1 test]# cat a.txt ## 测试文本,假设第一行是表头 01 02 03 04 05 06 07 08 09 10 11 12 13 阅读全文
posted @ 2025-07-16 09:11
小鲨鱼2018
阅读(7)
评论(0)
推荐(0)
摘要:
python中对二维列表进行转置 001、实现方法1:使用zip*解包和list函数 >>> list1 = [["aa", "bb", "cc"], [100, 300, 500], ["kk", "xx", "yy"], [88, 22, 33]] ## 测试列表 >>> list1 [['aa 阅读全文
posted @ 2025-07-16 09:06
小鲨鱼2018
阅读(21)
评论(0)
推荐(0)
摘要:
python中map函数的用法 001、批量转换数据类型 >>> str1 ## 测试字符串 '123456789' >>> for i in str1[5:]: ... print(i, type(i)) ... 6 <class 'str'> ## 迭代输出为字符型 7 <class 'str' 阅读全文
posted @ 2025-07-16 08:49
小鲨鱼2018
阅读(14)
评论(0)
推荐(0)
摘要:
001、 python中对列表进行排序,限定数值型: >>> list1 = [2,1,5,10,3,7] ## 测试列表1,数值型,可以直接排序 >>> sorted(list1) [1, 2, 3, 5, 7, 10] >>> list1 = ["2","1","5","10","3","7"] 阅读全文
posted @ 2025-07-16 08:46
小鲨鱼2018
阅读(4)
评论(0)
推荐(0)