filmov
tv
16 Python String Methods in 1 Minute! Part 3

Показать описание
Explore 16 more essential Python string methods in this quick tutorial!
Timestamps:
00:00 - format(), format_map()
"format() inserts specified values into placeholders in the string. For example, 'Hello, {}!' becomes 'Hello, world!'."
"format_map() is similar to format(), but uses a dictionary to map values into placeholders. For example, 'Hello, {name}!' becomes 'Hello, world!' when using the dictionary {'name': 'world'}."
00:07 - isdecimal(), isidentifier()
"isdecimal() checks if all characters in a string are decimal numbers. '12345' is decimal."
"isidentifier() checks if the string is a valid identifier in Python. 'variable_name' is a valid identifier."
00:15 - isnumeric(), isprintable()
"isnumeric() checks if all characters in a string are numeric. '12345' is numeric."
"isprintable() checks if all characters in a string are printable. 'Hello, world!' is printable."
00:22 - isspace(), istitle()
"isspace() checks if all characters in a string are whitespace. ' ' (spaces only) is whitespace."
"istitle() checks if the string is title-cased. 'Hello World' is title-cased."
00:30 - ljust(), removeprefix()
"ljust() left-justifies the string in a field of a specified width. 'hello' becomes 'hello-----'."
"removeprefix() removes a specified prefix from the start of the string. 'unhappy' becomes 'happy'."
00:37 - removesuffix(), rfind()
"removesuffix() removes a specified suffix from the end of the string. 'testing' becomes 'test'."
"rfind() returns the highest index of a substring in the string. 'hello world' finds 'o' at index 7."
00:45 - rjust(), rsplit()
"rjust() right-justifies the string in a field of a specified width. 'hello' becomes '-----hello'."
"rsplit() splits the string into a list, starting from the right. 'one two three' becomes ['one', 'two', 'three']."
00:52 - splitlines(), isascii()
"splitlines() splits the string at line breaks and returns a list of lines. 'hello\nworld' becomes ['hello', 'world']."
"isascii() checks if all characters in the string are ASCII. 'hello' is ASCII."
Timestamps:
00:00 - format(), format_map()
"format() inserts specified values into placeholders in the string. For example, 'Hello, {}!' becomes 'Hello, world!'."
"format_map() is similar to format(), but uses a dictionary to map values into placeholders. For example, 'Hello, {name}!' becomes 'Hello, world!' when using the dictionary {'name': 'world'}."
00:07 - isdecimal(), isidentifier()
"isdecimal() checks if all characters in a string are decimal numbers. '12345' is decimal."
"isidentifier() checks if the string is a valid identifier in Python. 'variable_name' is a valid identifier."
00:15 - isnumeric(), isprintable()
"isnumeric() checks if all characters in a string are numeric. '12345' is numeric."
"isprintable() checks if all characters in a string are printable. 'Hello, world!' is printable."
00:22 - isspace(), istitle()
"isspace() checks if all characters in a string are whitespace. ' ' (spaces only) is whitespace."
"istitle() checks if the string is title-cased. 'Hello World' is title-cased."
00:30 - ljust(), removeprefix()
"ljust() left-justifies the string in a field of a specified width. 'hello' becomes 'hello-----'."
"removeprefix() removes a specified prefix from the start of the string. 'unhappy' becomes 'happy'."
00:37 - removesuffix(), rfind()
"removesuffix() removes a specified suffix from the end of the string. 'testing' becomes 'test'."
"rfind() returns the highest index of a substring in the string. 'hello world' finds 'o' at index 7."
00:45 - rjust(), rsplit()
"rjust() right-justifies the string in a field of a specified width. 'hello' becomes '-----hello'."
"rsplit() splits the string into a list, starting from the right. 'one two three' becomes ['one', 'two', 'three']."
00:52 - splitlines(), isascii()
"splitlines() splits the string at line breaks and returns a list of lines. 'hello\nworld' becomes ['hello', 'world']."
"isascii() checks if all characters in the string are ASCII. 'hello' is ASCII."