Files
freeCodeCamp/guide/russian/python/data-structures/strings/index.md
2018-10-16 21:32:40 +05:30

36 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: The Python Strings
localeTitle: Строки Python
---
Python позволяет `str` объектам или _строкам_ выражаться несколькими способами:
* Одиночные кавычки: `'Single quote strings can have "double" quotes inside.'`
* Двойные кавычки: `"Double quote strings can have 'single' quotes inside."` двойными кавычками `"Double quote strings can have 'single' quotes inside."`
* Тройной котировки:
```
"""Triple quoted strings can span multiple lines.
Unescaped "double" and 'single' quotes in triple quoted strings are retained."""
'''Triple quoted strings can be 'single'or "double" quotes.
Unescaped newlines are also retained.'''
```
* Неизменяемость: вы не можете напрямую редактировать / изменять строку Python после ее создания. Например, если вы попытаетесь напрямую переназначить / изменить первую букву в строке, возникает ошибка.
```
>>> foo = "my string"
>>> foo[0] = "a"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object does not support item assignment
```
## Справка:
[Тип текстовой последовательности _str_](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)