生信_Python 基础

2023-10-17  本文已影响0人  重拾生活信心

Python for Bioinformatics

Data types

数据类型

容器类型

my_list = ['hello!', 'world']
my_tupple = ('hello!', 'world') 
my_dictionary= {'hi!' : 'hello!'  ,  '88' : 'Bye!' }
my_set = {'hello!', 'world'}

列表list [,]

元组tuple (,)

字典dict { : , : }

{ key :value }

集合set { , }

Operations for sequences

Strings

List

Adding
Removing

Common Properties of Sequences [list \ tuple \ strings]

Indexing : []
seqdata = (’MRVLLVALALLA’, 12, ’5FE9EEE8EE2DC2C7’) 
seqdata[0][5]
 ’V’
Slicing : :
Membership Test : in
>>> point = (23, 56, 11)
>>> 11 in point True 
>>> my_sequence = ’MRVLLVALALLALAASATS’ 
>>> ’X’ in my_sequence 
False
Concatenation 连接
c()
len, max, and min
Turn a Sequence into a List

To convert a sequence (like a tuple or a string) into a list, use the list() method:

>>> tata_box = ’TATAAA’ 
>>> list(tata_box) [’T’, ’A’, ’T’, ’A’, ’A’, ’A’]
Dictionaries
dic dictionary_view
Set

Reference

上一篇 下一篇

猜你喜欢

热点阅读