随笔分类 - python
摘要:001、方法1 >>> list1 = ["aaa", "bbb", "ccc"] >>> list2 = [100, 500, 300] >>> dict1 = dict(zip(list1, list2)) >>> dict1 {'aaa': 100, 'bbb': 500, 'ccc': 30
阅读全文
摘要:001、 [root@pc1 test]# ls a.txt test.py [root@pc1 test]# cat a.txt 1 2 3 4 5 [root@pc1 test]# cat test.py #!/usr/bin/python in_file = open("a.txt", "r"
阅读全文
摘要:001、 [root@pc1 test]# cat a.fa >chr1 aatt cc >chr2 ttgg ccgg >chr3 aa [root@pc1 test]# cat test.py #!/usr/bin/python in_file = open("a.fa", "r") dict1
阅读全文
摘要:001、问题 AttributeError: module 'importlib._bootstrap_external' has no attribute '_w_long' 002、原因 pip版本和对应的python调用不是同一个版本 003、解决方法 查找环境变量, 将pip命令和pytho
阅读全文
摘要:001、问题 ModuleNotFoundError: No module named '_sqlite3' 002、问题原因’ 安装python的时候没有找到sqlite3.so的库。 003、解决方法 yum install sqlite* 004、然后重新编译python3 ./configu
阅读全文
摘要:001、问题 ModuleNotFoundError: No module named 'pandas' 002、解决方法 pip install pandas -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com 003、
阅读全文
摘要:001、问题 [root@localhost test]# /home/software/Python-3.7.9/python Python 3.7.9 (default, Oct 21 2022, 23:48:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
阅读全文
摘要:001、问题 [root@localhost Python-3.7.9]# python --version Python 3.7.9 [root@localhost Python-3.7.9]# pip Traceback (most recent call last): File "/bin/p
阅读全文
摘要:001、问题 bash: pip: command not found... 002、python版本 [root@localhost pool]# python --version Python 2.7.5 003、解决方法 wget https://bootstrap.pypa.io/pip/2
阅读全文
摘要:001、打开python shell root@ubuntu01:/home/software# python Python 2.7.18 (default, Jul 1 2022, 10:30:50) [GCC 11.2.0] on linux2 Type "help", "copyright",
阅读全文
摘要:001、问题 002、解决方法(安装python依赖的环境): apt-get install python2-dev apt-get install python3-dev
阅读全文
摘要:001、系统 root@ubuntu01:/home# hostnamectl Static hostname: ubuntu01 Icon name: computer-vm Chassis: vm Machine ID: e6fb52b4c8414f29b06dc95d57b5846c Boot
阅读全文
摘要:001、 >>> import re >>> s1 = "ATGXAGXATGETAGETAGATGXXY" >>> re.findall('ATG|TAG', s1) ## 同时对字符串s1中的两个字符串进行查找 ['ATG', 'ATG', 'TAG', 'TAG', 'ATG']
阅读全文
摘要:001、 >>> list1 = ["aaa", "bbb", "ccc"] ## 测试列表(可以是任意可迭代对象) >>> dict1 = {} ## 空字典 >>> dict1.fromkeys(list1, "") ## 将列表的值作为键生成字典 {'aaa': '', 'bbb': '',
阅读全文
摘要:001、 >>> list1 = ["aa", "bb", "aa", "cc", "aa", "aa", "cc","ee"] ## 测试列表 >>> list1 ['aa', 'bb', 'aa', 'cc', 'aa', 'aa', 'cc', 'ee'] >&g
阅读全文
摘要:001、 >>> [[0] * 5 for i in range(3)] ## 生成3行5列,元素为0的矩阵 [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]] 002、 >>> [ [1, 2, 3] * 2 for i in range(6)]
阅读全文
摘要:pyhton 中内置函数enumerate用于将序列生成二元组。 001、 >>> str1 = "hello!" ## 测试字符串 >>> for i in enumerate(str1): ## enumerate用于将序列生成二元组 ... print(i) ... (0, 'h') (1,
阅读全文
摘要:001、 >>> test1 = [] >>> test1 [] >>> if not test1: ## 判断列表为空 ... print("no element") ... no element 002、 >>> test1 = () >>> test1 () >>> if not test1:
阅读全文
摘要:001、读取fasta文件 root@PC1:/home/test# ls a.fasta root@PC1:/home/test# cat a.fasta ## 测试数据 >Rosalind_1 ATCCAGCT >Rosalind_2 GGGCAACT >Rosalind_3 ATGGATCT
阅读全文
摘要:001、 root@PC1:/home/test# ls a.fasta test.py root@PC1:/home/test# cat a.fasta ## 测试数据 >Rosalind_1 ATCCAGCT >Rosalind_2 GGGCAACT >Rosalind_3 ATGGATCT >
阅读全文

浙公网安备 33010602011771号