s.strip() .lstrip() .rstrip(',') 去空格及特殊符号
复制字符串
Python
1
#strcpy(sStr1,sStr2)
2
sStr1
=
'strcpy'
3
sStr2
=
sStr1
4
sStr1
=
'strcpy2'
5
print
sStr2
连[……]
[…]
|
||||||
s.strip() .lstrip() .rstrip(',') 去空格及特殊符号 复制字符串Python 1 #strcpy(sStr1,sStr2) 2 sStr1 = 'strcpy' 3 sStr2 = sStr1 4 sStr1 = 'strcpy2' 5 print sStr2 连[……][…] def stdDeviation(a): l=len(a) m=sum(a)/l d=0 for i in a: d+=(i-m)**2 return (d*(1/l))**0.5 a=[5,6,8,9] print(stdDeviation(a)) ======== 1.5811388300841898 […] #!/usr/bin/python #filename:string.py import string print string.atoi(’13’,8) #这里转换8进制的数 print string.atoi(’13’,16) #这里转换成16进制的数 运行后的结果: 11 19 >>> import string >>> string.atoi(’13’,8) 11 >>> string.atoi(’13’,10) 13 >>> string.at[……] […] >>> a ‘[acyl-carrier-protein] S-malonyltransferase [EC:2.3.1.39]’ >>> b = re.findall(r'(?<=\[EC:).+?(?=\])’,a) >>> b [‘2.3.1.39′] >>> b = re.findall(r'(?<=\[).+?(?=\])’,a) >>> b [‘acyl-carrier-protein’, ‘EC:2.3.1.39′] 前向界定与后向界定 有时候需要[……] […] dic_cog_annot[h2[1]]={‘orthologous_group':h[3]} dic_cog_annot[h2[1]][‘protein_annot’]=h[4] 以上是增加个protein_annot键值, 如果是以下,将会被替换,只一个键值! dic_cog_annot[h2[1]]={‘orthologous_group':h[3]} dic_cog_annot[h2[1]]={‘protein_annot':h[4]} dic[name]=”NA” dic[name] = {‘nr_annot':”NA”} dic[[……] […] method1: dic = {} keys= dic.keys() keys.sort() for key in keys: print dic[key] method2: for key in sorted(write_list_hash.keys()): print write_list_hash[key] […] #! /usr/bin/env python2.7 desc = """ Split an ACE format assembly file into multiple single ACE files each with a single contig. The resulting ACE contig files are formatted so that they can be read by CodonCode (http://www.codoncode.com). $ ACEAssemblySplitter.py test.ace -s 2 -e[......] […] a=[‘a’,’b’,’c’,’a’,’d’,’a’] 如何把所有的’a’删除呢? 我的笨方法: for i in a: if i == ‘a': a[a.index(i)] = ” while ” in a: a.remove(”) […] |
||||||
Copyright © 2023 小生这厢有礼了(BioFaceBook Personal Blog) - All Rights Reserved Powered by WordPress & Atahualpa |
Recent Comments