admin管理员组

文章数量:1612831

As mentioned in the previous chapter, some data structures are shared between

different computer languages, but some of them are language specific. That is why

data types somehow define a computer language. Python has its own characteristic

data types.

One such fundamental data structure is a sequence. Inside a sequence, the elements have a sequential order. For example the string, which is an ordered sequence of characters. Other sequences are lists and tuples.1 Although fundamental

differences exist between these types of sequences, they share common properties.

Sequence elements have an order, can be indexed, can be sliced, and can be iterated.

Don’t worry if you don’t understand some of these terms. Just keep on reading.

We’ll see all these points during this chapter.

Apart from sequences, there are also unordered data types: dictionaries and sets. A dictionary2

stores relationships between a key and a value, while a set is just an

unordered collection of values. The next pages are focused on ordered (string, list,

and tuple) and unordered types (dictionary and set).

3.1 STRINGS

A string is a sequence of symbols delimited by a single quote (’), double quotes

("), triple single quotes (”’), or triple double quotes ("""). Therefore, the following

strings are equivalent:

"This is a string in Python"

’This is a string in Python’

’’’This is a string in Python’’’

"""This is a string in Python"""

本文标签: fundamentalPythonstructurepythonPDFBioinformatics