Python Ljust String Method
Be sure to like, share and comment to show your support for our tutorials.
=======================================
Channel - https://goo.gl/pnKLqE
Playlist For This Tutorial - https://goo.gl/EyZFti
Latest Video - https://goo.gl/atWRkF
Facebook - https://www.facebook.com/mastercodeonline/
Twitter - https://twitter.com/mastercodeonlin?lang=en
Website - http://mastercode.online
======================================
Python Ljust String Method
In this Python tutorial, we will look at the Python ljust string method which will left justify a string string object. The ljust string method takes two arguments. The first argument is how many index positions the new string object should span and the second argument is the separator which must be in a string format.
Python Ljust String Method Syntax
'String Object'.ljust(index, 'separator')
'String Object' - This is our string object that will be left justified
.ljust(index, 'separator') - Ljust string method takes two arguments first one being how many index positions do you want your new string object to span and the second is the separator which will hold the new index positions.
Examples Of The Python Ljust String Method
#Example 1
'This is a string'.ljust(50)
'This is a string '
#Example 2
'This is a string'.ljust(50, '+')
'This is a string++++++++++++++++++++++++++++++++++'
#Example 3
'This is a string'.ljust(17, '!')
'This is a string!'
Examples Explained
Example 1:
'This is a string'.ljust(50) - We create a string object and call the ljust string method on the string object. The string method takes one argument of 50 which is the number of index positions you would like a string to expand.
'This is a string ' - We are returned a new string that contains 50 index positions with the previous string method positioned to the left.
Example 2:
'This is a string'.ljust(50, '+') - We create a string object and call the ljust string method on our string object. Our string method takes two arguments first is 50 index positions and second is the '+' symbol which will replace our default spaces to the right of our new string object.
'This is a string++++++++++++++++++++++++++++++++++' - We are returned a string that is left justified and the default spaces are replaced by '+'.
Example 3:
'This is a string'.ljust(17, '!') - We create a string object and call the ljust string method on our string object. Our string method takes two arguments. The first argument is 17 index positions and the second is the '!' which will replace the default space with a '!'.
'This is a string!' - We are returned a string with a '!' at the end.
*Note - If we provide an argument that is less than the length of the string then we are returned just the string.
Conclusion
In this Python tutorial we took a look at the Python ljust string method. If you have any questions about the ljust string method leave a comment below and we will help you.
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Python Ljust String Method», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.