Python Lstrip String Method
T0 learn more about our Python Programming Course visit http://mastercode.online/course/pro-python-programmer/
Python Lstrip String Method
In this Python tutorial, we will explore the Python lstrip string method. The lstrip string method allows us to remove content from the left side of a string. The lstrip string method takes one argument in a string format. This argument will remove any combination of the characters in the string object that is contained in the argument. If there is no argument provided to the lstrip string method, then the method will revert to a default white space.
Python Lstrip String Method Syntax
'String Object'.lstrip('characters to be removed')
'String Object' - This is our string object that we are going to remove content from the left side of the string.
.lstrip('characters to be removed') - The lstring string method has one optional argument. This argument will remove any combination characters in the argument from the left of the string object. The default argument is white space if we do not include an argument then Python will remove any spaces from the left side of the string.
Examples Of The Python Lstrip String Method
#Example 1
' This is a string '.lstrip()
'This is a string '
#Example 2
'abcdef'.lstrip('cba')
'def'
#Example 3
'abcdef'.lstrip('ABC')
'abcdef'
#Example 4
'http://www.learnpython.com'.lstrip('/:.wpth')
'learnpython.com'
Examples Explained
Example 1:
' This is a string '.lstrip() - We create a string object that contains spaces on the left and right side of the string object. Then we call the lstrip string method on the string object.
'This is a string ' - We are returned a new string object with the spaces on the left removed since the default argument for the lstrip string method is spaces.
Example 2:
'abcdef'.lstrip('cba') - We create a new string object and call the lstrip string method on our string object. Our string method takes an argument of 'cba' so if any of these characters show up in our string object they will be removed.
'def' - We are returned 'def' since our arguments met the first three characters of our string object.
Example 3:
'abcdef'.lstrip('ABC') - We create a string object and call lstrip string method on our string object. We provide an argument of 'ABC'.
'abcdef' - We are returned the same string since the argument is case sensitive so it did not match any of the characters in the string object.
Example 4:
'http://www.learnpython.com'.lstrip('/:.wpth') - We create a string object that contains a web address and then we call the lstrip string method to remove the 'http://www.' from the web address. We only need to add one character to the argument.
'learnpython.com' - We are returned a web address with the 'http://www.' removed.
Conclusion
In this Python tutorial we look at the Python lstrip string method. This method allows us to remove content from the left side of a string. If you have any questions about the lstrip string method leave a comment below.
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Python Lstrip String Method», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.