Читать книгу Introduction to Python Programming for Business and Social Science Applications - Frederick Kaefer - Страница 82

String Methods

Оглавление

Like lists, strings also have many methods. Table 3.2 identifies and gives a description of some commonly used string methods. A complete list of Python string methods is available in the Python documentation (Python Software Foundation, 2019, “String Methods”).

Table 3.2

Unlike lists, strings are immutable, meaning that their values are not able to be modified. The methods listed in Table 3.2 all return values, which in some cases are copies of the string on which we are applying the method. Note that even though we cannot modify a string, we can replace it with another string. Therefore, we can assign the returned copy from the use of a string method back to the string, replacing it.

Introduction to Python Programming for Business and Social Science Applications

Подняться наверх