随笔分类 - python
摘要:001、del删除 >>> dict1 = dict(a = 100, b = 200, c = 300, d = 400) >>> dict1 {'a': 100, 'b': 200, 'c': 300, 'd': 400} >>> del dict1['b'] ## 删除元素b >>> dict
阅读全文
摘要:001、 root@PC1:/home/test2# ls outcome.ped test.py root@PC1:/home/test2# cat outcome.ped ## 测试数据 1 G G C C G G 2 G G G C G G 3 G G C C G G 4 G G C C G
阅读全文
摘要:001、 root@PC1:/home/test2# ls outcome.map test.map root@PC1:/home/test2# cat outcome.map ## 测试数据 1 snp1 0 55910 1 snp2 0 85204 1 snp3 0 122948 1 snp4
阅读全文
摘要:001、 root@PC1:/home/test3# ls test.py root@PC1:/home/test3# cat test.py #!/usr/bin/python import argparse parser = argparse.ArgumentParser() parser.ad
阅读全文
摘要:1、找到python IDLE安装目录(我这里是:C:\Users\jim\AppData\Local\Programs\Python\Python310\Lib\idlelib) 在该目录下增加文件:ClearWindow.py 文件内容如下: """ Clear Window Extension
阅读全文
摘要:1、测试数据下载:ftp://ftp.ensemblgenomes.org/pub/plants/release-44/gff3/arabidopsis_thaliana/Arabidopsis_thaliana.TAIR10.44.chromosome.1.gff3.gz 2、 [root@PC1
阅读全文
摘要:001、测试数据 [root@PC1 test2]# ls a.fa test.py [root@PC1 test2]# cat a.fa ## 测试数据 >OR4F5_ENSG00000186092_ENST00000641515_61_1038_2618 CCCAGATCTCTTCAGTTTTT
阅读全文
摘要:001、 [root@PC1 test2]# ls a.txt b.txt test.py x.csv y.csv [root@PC1 test2]# pwd /home/test2 [root@PC1 test2]# cat test.py ## 脚本 #!/usr/bin/python impo
阅读全文
摘要:1、合并txt文件 [root@PC1 test2]# ls a.txt b.txt c.txt test.py x.csv y.csv [root@PC1 test2]# cat a.txt a a a b b b [root@PC1 test2]# cat b.txt c c c d d d [
阅读全文
摘要:1、内置函数remove >>> a = set([100, 200, 300]) >>> a {200, 100, 300} >>> type(a) <class 'set'> >>> a.remove(200) ## 内置函数remove删除指定元素 >>> a {100, 300} 2、清空集
阅读全文
摘要:1、内置函数add >>> a = {4, 5} >>> a {4, 5} >>> type(a) <class 'set'> >>> a.add(100) ## 利用内置函数add添加元素 >>> a {100, 4, 5} >>> a.add(500) >>> a {100, 500, 4, 5
阅读全文
摘要:1、利用键索引直接添加 >>> dict1 = dict(zip(["aa", "bb", "cc"], [100, 200, 300])) >>> dict1 {'aa': 100, 'bb': 200, 'cc': 300} >>> dict1["dd"] = 400 ## 利用键索引直接添加
阅读全文
摘要:1、利用内置函数pop删除 >>> dict1 = dict(a = 100, b = 200, c = 300, d = 400, e = 500) >>> dict1.pop("b") ## 内置函数pop删除,需指定键 200 >>> dict1 {'a': 100, 'c': 300, 'd
阅读全文
摘要:001、update函数合并 >>> a = {"aaa":100, "bbb":200, "ccc":300} >>> a {'aaa': 100, 'bbb': 200, 'ccc': 300} >>> b = dict(ccc = 400, ddd = 500, eee = 600) >>>
阅读全文
摘要:001、直接使用花括号 >>> dict1 = {"aaa":100, "bbb":200, "ccc":300} ## 每一项包括键和值,中间用冒号连接 >>> dict1 {'aaa': 100, 'bbb': 200, 'ccc': 300} >>> type(dict1) <class 'd
阅读全文
摘要:001、enumerate: >>> a = ["xx", "aa", "tt", "cc"] >>> a ['xx', 'aa', 'tt', 'cc'] >>> for i in enumerate(a): ## enumerate返回可迭代对象的索引值,生成二元组 ... print(i) .
阅读全文
摘要:1、将文本中的所有d替换为QQ [root@PC1 test3]# ls a.txt test.py [root@PC1 test3]# cat a.txt erg iuy dfg fdf er4 435 dft 34f cgd err [root@PC1 test3]# cat test.py #
阅读全文
摘要:1、删除第一列 [root@PC1 test3]# ls a.txt test.py [root@PC1 test3]# cat a.txt 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2
阅读全文
摘要:1、 >>> a = list(range(0, 11)) ## 列表 >>> a [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>> import numpy as np >>> np_a = np.array(a) >>> list(np_a[[1, 3, 7]]) #
阅读全文
摘要:1、删除第1行 [root@PC1 test2]# ls a.txt test.py [root@PC1 test2]# cat a.txt 01 11 21 31 02 12 22 32 03 13 23 33 04 14 24 34 05 15 25 35 06 16 26 36 [root@P
阅读全文

浙公网安备 33010602011771号