随笔分类 -  python

上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 26 下一页
摘要:001、 >>> a = {"b":500, "c":300, "a":700, "d":888} ## 测试字典 >>> a {'b': 500, 'c': 300, 'a': 700, 'd': 888} >>> sorted(a.items(), key = lambda x: x[0]) # 阅读全文
posted @ 2022-08-08 15:23 小鲨鱼2018 阅读(159) 评论(0) 推荐(0)
摘要:001、 >>> a = lambda x: x + 10 ## 直接定义函数 >>> a(5) 15 >>> a(100) 110 >>> b = lambda x: x * 5 ## 直接定义函数 >>> b(5) 25 >>> b(100) 500 阅读全文
posted @ 2022-08-08 15:17 小鲨鱼2018 阅读(43) 评论(0) 推荐(0)
摘要:001、 >>> a = [1, 3, 6] >>> sum(a)/len(a) 3.3333333333333335 >>> round(sum(a)/len(a), 2) ## 保留两位有效数字 3.33 >>> round(sum(a)/len(a), 4) ## 保留四位有效数字 3.333 阅读全文
posted @ 2022-08-08 13:47 小鲨鱼2018 阅读(355) 评论(0) 推荐(0)
摘要:001、利用列表实现 (base) root@PC1:/home/test# ls a.fasta test.py (base) root@PC1:/home/test# cat a.fasta ## 测试数据 >scaffold_1 CCCGGGTAAAACGGGTCTTCAAGAAAACGCTC 阅读全文
posted @ 2022-08-08 13:39 小鲨鱼2018 阅读(183) 评论(0) 推荐(0)
摘要:001、 (base) root@PC1:/home/test# ls a.fasta test.py (base) root@PC1:/home/test# cat a.fasta ## 测试数据 >scaffold_1 CCCGGGTAAAACGGGTCTTCAAGAAAACGCTCCTCCGT 阅读全文
posted @ 2022-08-08 12:51 小鲨鱼2018 阅读(286) 评论(0) 推荐(0)
摘要:001、 (base) root@PC1:/home/test# ls ## 测试数据及脚本 a.fasta test.py (base) root@PC1:/home/test# cat a.fasta ## 测试数据 >scaffold_1 CCCGGGTAAAACGGGTCTTCAAGAAAA 阅读全文
posted @ 2022-08-08 12:38 小鲨鱼2018 阅读(246) 评论(0) 推荐(0)
摘要:001、 >>> import re ## 导入re包 >>> str = "abcaabxyxy" >>> re.findall('a', str) ## 返回所有的a,生成列表 ['a', 'a', 'a'] >>> re.findall('b', str) ['b', 'b'] >>> re. 阅读全文
posted @ 2022-08-07 22:36 小鲨鱼2018 阅读(97) 评论(0) 推荐(0)
摘要:001、 root@PC1:/home/test# ls test.fasta test.py root@PC1:/home/test# cat test.fasta ## 测试文件 >scaffold_1 CCCGGGTAAAACGGGTCTTCAAGAAAACGCTCCTCCGTTAATGCCG 阅读全文
posted @ 2022-08-07 22:30 小鲨鱼2018 阅读(481) 评论(0) 推荐(0)
摘要:001、 root@PC1:/home/test# ls test.fasta test.py root@PC1:/home/test# cat test.fasta ## 测试数据 >scaffold_1 CCCGGGTAAAACGGGTCTTCAAGAAAACGCTCCTCCGTTAATGCCG 阅读全文
posted @ 2022-08-07 21:09 小鲨鱼2018 阅读(574) 评论(0) 推荐(0)
摘要:001、 root@PC1:/home/test# cat test.fasta ## 测试数据 >scaffold_1 CCCGGGTAAAACGGGTCTTCAAGAAAACGCTCCTCCGTTAATGCCGGCCGATTCAAATAA CGCTGATTCTGATTCAGGATATACAATC 阅读全文
posted @ 2022-08-07 19:03 小鲨鱼2018 阅读(81) 评论(0) 推荐(0)
摘要:001、 root@PC1:/home/test# ls test.fastq test.py root@PC1:/home/test# cat test.fastq ## 测试fastq文件 @A00530:26:H35FTDSXX:4:1101:6614:1047 1:N:0:AACGTGAT 阅读全文
posted @ 2022-08-06 22:58 小鲨鱼2018 阅读(707) 评论(0) 推荐(0)
摘要:001、创建函数 >>> def test_fun(): ## 创建函数 ... print("hello world!") ... >>> test_fun() ## 调用函数 hello world! 002、顺序参数、关键字参数 >>> def test_fun(x,y): ## 定义函数, 阅读全文
posted @ 2022-08-06 15:05 小鲨鱼2018 阅读(208) 评论(0) 推荐(0)
摘要:001、 >>> test1 = dict(c = 200, a = 400, d = 300, b = 700) >>> test1 {'c': 200, 'a': 400, 'd': 300, 'b': 700} >>> test2 = {} >>> temp = [] >>> for i in 阅读全文
posted @ 2022-08-06 14:38 小鲨鱼2018 阅读(59) 评论(0) 推荐(0)
摘要:001、 >>> test1 = dict(a = 100, b = 200, c = 300, d = 400) >>> test1 {'a': 100, 'b': 200, 'c': 300, 'd': 400} >>> test2 = dict() >>> for i,j in test1.i 阅读全文
posted @ 2022-08-06 14:34 小鲨鱼2018 阅读(189) 评论(0) 推荐(0)
摘要:001、 >>> test1 = ["aaa", "bbb", "ccc", "ddd"] >>> test1 ['aaa', 'bbb', 'ccc', 'ddd'] >>> '_'.join(test1) ## 列表转换为字符串 'aaa_bbb_ccc_ddd' >>> test2 = '_' 阅读全文
posted @ 2022-08-06 14:22 小鲨鱼2018 阅读(80) 评论(0) 推荐(0)
摘要:001、 >>> test1 = dict(c = 500, a = 300, b = 200, e = 600, d = 777) >>> test1 {'c': 500, 'a': 300, 'b': 200, 'e': 600, 'd': 777} >>> test2 = dict() >>> 阅读全文
posted @ 2022-08-06 14:18 小鲨鱼2018 阅读(61) 评论(0) 推荐(0)
摘要:001、排序 a、 >>> test = [8, 2, 5, 9, 3] >>> test [8, 2, 5, 9, 3] >>> test.sort() ## 直接在原始列表中排序 >>> test [2, 3, 5, 8, 9] >>> test = [8, 2, 5, 9, 3] >>> te 阅读全文
posted @ 2022-08-06 13:19 小鲨鱼2018 阅读(90) 评论(0) 推荐(0)
摘要:001、 >>> dict1 = {} >>> dict1 {} >>> dict2 = dict() >>> dict2 {} 002、fromkeys创建 >>> dict1 = {} >>> dict1 {} >>> dict1.fromkeys(['a', 'b', 'c']) ## 值为空 阅读全文
posted @ 2022-08-06 13:05 小鲨鱼2018 阅读(2362) 评论(0) 推荐(0)
摘要:001、复制方式1 >>> dict1 = dict(a = 100, b = 200, c = 300, d = 400) >>> dict1 {'a': 100, 'b': 200, 'c': 300, 'd': 400} >>> dict2 = dict1 ## 直接赋值, 原始字典变化,复制 阅读全文
posted @ 2022-08-06 12:56 小鲨鱼2018 阅读(809) 评论(0) 推荐(0)
摘要:001、 >>> dict1 = dict(a = 100, b = 200, c = 300, d = 400) >>> dict1 {'a': 100, 'b': 200, 'c': 300, 'd': 400} >>> dict1['e'] = 500 ## 添加元素e >>> dict1 { 阅读全文
posted @ 2022-08-06 12:51 小鲨鱼2018 阅读(312) 评论(0) 推荐(0)

上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 26 下一页