随笔分类 - python
摘要:001、 python中格式化字符串f的用法
阅读全文
摘要:001、 [root@PC1 test]# ls hello.py [root@PC1 test]# cat hello.py #!/usr/bin/env python # -*- coding:utf-8 -*- import argparse ## 导入模块 parser = argparse
阅读全文
摘要:001、python中tqmd函数实现for循环的进度条 [root@PC1 test]# ls test.py [root@PC1 test]# cat test.py #!/usr/bin/env python # -*- coding:utf-8 -*- from tqdm import tq
阅读全文
摘要:001、 读取数据,并显示数据的维度 [root@PC1 test]# ls a.out test.py [root@PC1 test]# cat a.out ## 测试数据 id pos gpos p1 ihh1 . 7111 0.007111 0.139456 0.00604659 . 7148
阅读全文
摘要:if __name__ == "__main__": main() 语句的作用 001、 [root@PC1 test]# ls script.py test.py [root@PC1 test]# cat script.py ## 测试程序script.py #!/usr/bin/env pyth
阅读全文
摘要:sample_to_row = {row[0]: row for row in lines[1:]} 001、sample_to_row = {row[0]: row for row in lines[1:]}
阅读全文
摘要: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
阅读全文
摘要:001、 >>> from collections import defaultdict ## 从collections模块中导入defaultdict类 >>> dict1 = {} ## 定义普通字典 >>> dict1["kk"] ## 当索引一个不存在的健 Traceback (most r
阅读全文
摘要: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.
阅读全文
摘要: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
阅读全文
摘要:python中对二维列表进行转置 001、实现方法1:使用zip*解包和list函数 >>> list1 = [["aa", "bb", "cc"], [100, 300, 500], ["kk", "xx", "yy"], [88, 22, 33]] ## 测试列表 >>> list1 [['aa
阅读全文
摘要:python中map函数的用法 001、批量转换数据类型 >>> str1 ## 测试字符串 '123456789' >>> for i in str1[5:]: ... print(i, type(i)) ... 6 <class 'str'> ## 迭代输出为字符型 7 <class 'str'
阅读全文
摘要: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"]
阅读全文
摘要:python 中的列表推导式 001、 >>> list1 = [[2,1,5],[3,2,8],[5,2,4],[8,2,1]] ## 测试列表 >>> for col in range(len(list1[0])): ... col_value = [ row[col] for row in l
阅读全文
摘要:python 中 if语句条件判断退出,并输出错误信息 001、 (base) [root@PC1 test]# cat test.py ## 测试程序 #!/usr/bin/env python # -*- coding:utf-8 -*- import sys list1 = [3, 8, 30
阅读全文
摘要:001、format格式化字符串 a、 >>> "{} {}={}".format("aa", "bb", "cc") ## 默认是位置参数,格式化字符串位于{}中 'aa bb=cc' b、指定位置参数格式话 >>> "{2} {0}={1}".format("aa", "bb", "cc") #
阅读全文
摘要:001、 >>> os.listdir() ## 当前路径下的文件 ['a.txt'] >>> input_file = open("a.txt") ## 打开文件 >>> for i in input_file: ... i = i.strip() ... print(i) ... 01 02 0
阅读全文
摘要:001、 [root@PC1 test]# ls outcome.map test.py [root@PC1 test]# head -n 3 outcome.map ## 原始map文件 1 s64199.1 0 55910 1 OAR19_64675012.1 0 85204 1 OAR19_6
阅读全文
摘要:001、 shell zcat ${i}_trim_1P.fastq.gz | cat - <(zcat ${i}_trim_2P.fastq.gz) | awk 'NR % 4 == 0' > ${i}_quality.txt ## 将压缩后的fastq文件合并并提取出质量值 002、python
阅读全文
摘要:python中实现两个文件的cat型的合并
阅读全文

浙公网安备 33010602011771号