Python Part 14d - Working with strings

preview_player
Показать описание
By Andy Brown

This tutorial shows all the useful things that you can do with strings in Python, including joining and splitting them, using escape characters, finding and replacing text, changing case, justifying text and using regular expressions and translation tables.

Chapters
00:00 Topic list
01:48 Basic string operations
04:50 Escape characters
06:53 Revision of strings and sequencing
09:00 Editing strings
13:40 Joining and splitting text
17:48 Finding text
21:06 Changing case
23:31 Padding and justification
25:06 Checking string contents
29:29 Regular expressions
31:51 The string module and translations

If you'd like to help fund Wise Owl's conversion of tea and biscuits into quality training videos you can join this channel to get access to perks:

Рекомендации по теме
Комментарии
Автор

These videos are absolutely brilliant. Keep up the good work. Really appreciate your effort!

kp
Автор

great content Andy! they're all being really helpful, thanks a lot :)

danieloc
Автор

How can you not understand what maketrans function/ method does if its definition is displayed the moment you hover over it?

filipkotanski
Автор

In the "trans_table = str.maketrans('q', 'X', string.punctuation)" the first 2 argument allow an 'on the fly' character replacement - in this case "q" gets replaced by "X"

Sorry, following along with the vid or I would have used this as the example: "trans_table = str.maketrans('\n', ' ', string.punctuation)" does the job of the carriage return removal line while dumping the punctuation.

andrewt
Автор

According to ChatGPT

"isdigit(): Returns True if all characters in the string are digits, and there is at least one character.
Does not consider other numeric characters such as superscripts and subscripts as digits.

isnumeric(): Returns True if all characters in the string are numeric.
Considers other numeric characters such as superscripts, subscripts, fractions, roman numerals, etc., as numeric.

Now we know Nice that the Roman Empire is still represented (just another thing the Romans gave us [obscure Python joke])

andrewt