随笔分类 -  python

上一页 1 2 3 4 5 6 7 8 ··· 25 下一页
摘要:001、 >>> str1 = "ab_cd ef_gh ij_kl" ## 测试字符串 >>> str1.split(" ") ## 一句空格进行拆分 ['ab_cd', 'ef_gh', 'ij_kl'] >>> import re >>> re.split("[_| ]",str1) ## 同 阅读全文
posted @ 2023-06-06 11:37 小鲨鱼2018 阅读(81) 评论(0) 推荐(0) 编辑
摘要:001、 >>> import sys >>> print(sys.version) 2.7.5 (default, Jun 28 2022, 15:30:04) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] 阅读全文
posted @ 2023-06-06 11:32 小鲨鱼2018 阅读(14) 评论(0) 推荐(0) 编辑
摘要:001、python报错 >>> dict1 = {"aa":300, "bb":500, "cc":400, "dd":700} >>> dict1 {'aa': 300, 'bb': 500, 'cc': 400, 'dd': 700} >>> dict1.keys() dict_keys([' 阅读全文
posted @ 2023-06-02 13:05 小鲨鱼2018 阅读(603) 评论(0) 推荐(0) 编辑
摘要:001、python报错如下: >>> dict1 = {"aa":700, "bb":400, "cc":300, "dd":600} >>> dict1.values().index(300) Traceback (most recent call last): File "<stdin>", 阅读全文
posted @ 2023-06-02 12:58 小鲨鱼2018 阅读(147) 评论(0) 推荐(0) 编辑
摘要:001、 >>> dict1 = {"aa":500, "bb":400, "cc":700, "dd":300} >>> dict1 {'aa': 500, 'cc': 700, 'dd': 300, 'bb': 400} >>> dict1.keys()[dict1.values().index 阅读全文
posted @ 2023-06-02 00:27 小鲨鱼2018 阅读(29) 评论(0) 推荐(0) 编辑
摘要:两者都返回首次匹配字符串的索引,re.match函数只从头开始匹配, re.search函数不限制只从头开始匹配。 001、re.match函数 [root@PC1 test2]# python3 Python 3.10.9 (main, Mar 1 2023, 18:23:06) [GCC 11. 阅读全文
posted @ 2023-05-31 13:03 小鲨鱼2018 阅读(187) 评论(0) 推荐(0) 编辑
摘要:001、 [root@PC1 test3]# ls a.txt [root@PC1 test3]# cat a.txt ## 测试文件 10 2 3 0 3 6 6 12 1 1 5 1 2 2 2 4 2 26 8 3 33 34 5 3 [root@PC1 test3]# python ## 启 阅读全文
posted @ 2023-05-16 23:54 小鲨鱼2018 阅读(197) 评论(0) 推荐(0) 编辑
摘要:001、 [root@PC1 ~]# pip config list 002、 [root@PC1 ~]# cd ~ [root@PC1 ~]# ls -a . .bash_history .bashrc .cshrc Documents .ICEauthority Music Public .tc 阅读全文
posted @ 2023-05-16 01:07 小鲨鱼2018 阅读(821) 评论(0) 推荐(0) 编辑
摘要:python2.7中安装pip命令 001、 [root@PC1 test]# pip bash: pip: command not found... 002、 [root@PC1 test]# cat /etc/redhat-release 003、 [root@PC1 software]# cu 阅读全文
posted @ 2023-05-15 13:20 小鲨鱼2018 阅读(49) 评论(0) 推荐(0) 编辑
摘要:001、 >>> import re >>> tmp = re.match(r'^([^\s]+)\s(.*)', "ab cd") >>> tmp <re.Match object; span=(0, 5), match='ab cd'> >>> tmp.group(1) 'ab' >>> tmp 阅读全文
posted @ 2023-05-09 22:57 小鲨鱼2018 阅读(98) 评论(0) 推荐(0) 编辑
摘要:001、re.match >>> re.match("ab", "abcdefgab") ## 在字符串abcdefgab中查找字符串ab, 返回索引 <re.Match object; span=(0, 2), match='ab'> >>> re.match("xy", "abcdefgab") 阅读全文
posted @ 2023-05-09 20:48 小鲨鱼2018 阅读(385) 评论(0) 推荐(0) 编辑
摘要:001、 (base) [root@PC1 test3]# ls ## 测试数据及脚本 a.txt test.py (base) [root@PC1 test3]# cat test.py ## 复制程序 import os os.popen('cp a.txt b.txt') ## windows 阅读全文
posted @ 2023-03-22 21:27 小鲨鱼2018 阅读(87) 评论(0) 推荐(0) 编辑
摘要:001、python报错 SyntaxError: Non-ASCII character '\xe8' in file test.py on line 6 原因:注释行中出现了中文 ,而python支持的ASCII码不支持中文。 002、解决方法 在头文件中增加: # -*- coding: ut 阅读全文
posted @ 2023-02-27 09:29 小鲨鱼2018 阅读(716) 评论(0) 推荐(0) 编辑
摘要:001、 方法1 >>> list1 = [] >>> for i in range(5): ... list1.append("value") ... >>> list1 ['value', 'value', 'value', 'value', 'value'] 002、方法2 >>> list1 阅读全文
posted @ 2023-02-26 18:02 小鲨鱼2018 阅读(290) 评论(0) 推荐(0) 编辑
摘要:001、 [root@PC1 test]# ls outcome.map test.py [root@PC1 test]# cat outcome.map ## 测试数据 55910 85204 jj 122948 yy kk 203750 rr ee ss 312707 dd ff 356863 阅读全文
posted @ 2023-01-07 23:47 小鲨鱼2018 阅读(76) 评论(0) 推荐(0) 编辑
摘要:001、查看系统 [root@PC1 ~]# cat /etc/redhat-release CentOS Linux release 7.9.2009 (Core) 002、安装环境依赖 yum -y install gcc install zlib zlib-devel bzip2-devel 阅读全文
posted @ 2023-01-02 23:05 小鲨鱼2018 阅读(695) 评论(0) 推荐(0) 编辑
摘要:001、python3.11编译报错 /home/software/python/Modules/_ctypes/_ctypes.c:118:17: fatal error: ffi.h: No such file or directory 002、解决方法 [root@PC1 python]# y 阅读全文
posted @ 2023-01-02 13:19 小鲨鱼2018 阅读(1485) 评论(0) 推荐(0) 编辑
摘要:001、 问题 >>> from Bio import SeqIO 002、解决方法 pip3 install biopython -i https://pypi.douban.com/simple 003、测试效果 from Bio import SeqIO 阅读全文
posted @ 2022-11-19 22:57 小鲨鱼2018 阅读(1324) 评论(0) 推荐(0) 编辑
摘要:001、 [root@pc1 test2]# ls a.txt test.py [root@pc1 test2]# cat a.txt ## 测试序列 AGCTTCCCC [root@pc1 test2]# cat test.py ## 测试程序 #!/usr/bin/python in_file 阅读全文
posted @ 2022-11-16 18:21 小鲨鱼2018 阅读(176) 评论(0) 推荐(0) 编辑
摘要:001、match >>> import re >>> str1 = "www.baidu.com" ## 测试字符串 >>> re.match("www", str1) <re.Match object; span=(0, 3), match='www'> >>> re.match("www", 阅读全文
posted @ 2022-11-16 16:21 小鲨鱼2018 阅读(22) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 ··· 25 下一页
点击右上角即可分享
微信分享提示