RUVIDEO
Поделитесь видео 🙏

Python String. String Functions Python code with example. Python Complete Course Video # 8

📁 Обучение 👁️ 16 📅 02.12.2023

Python String
Strings in python are surrounded by either single quotation marks, or double quotation marks.
'guangshu' is the same as "guangshu".
You can display a string literal with the print() function
print('guangshu')
You can assign a multiline string to a variable by using three double quotes or three single quotes:
String as Array
Like many other popular programming languages, strings in Python are arrays of bytes representing unicode characters.
However, Python does not have a character data type, a single character is simply a string with a length of 1.
Square brackets can be used to access elements of the string.
a = "Guangshu Coder"
print(a[1])
output: u
Looping Through a String
Since strings are arrays, we can loop through the characters in a string, with a for loop
Example:
for x in "guangshu":
print(x)
String Length
To get the length of a string, use the len() function.
The len() function returns the length of a string:
Example:
a = "Guangshu Coder"
print(len(a))
output: 14
#python #coding #programming
Slicing String
To get the length of a string, use the len() function.
The len() function returns the length of a string:
Example:
a = "Guangshu Coder"
print(len(a))
output: 14
Modify String
Python has a set of built-in methods that you can use on strings
upper() method returns the string in upper case:
b = "Guangshu Coder"
print(b.upper()) output: GUANGSHU CODER
lower() method returns the string in lower case:
print(b.lower()) output: guangshu coder
strip() method removes any whitespace from beginning or the end
print(b.strip()) output: Guangshu Coder
replace() method replaces a string with another string:
print(b.replace("G", "H")) output: Huangshu Coder
split() method splits string into substrings
if it finds instances of the separator.
print(split("s")) output: ['Guang', 'hu Coder']
Python Complete Course
Playlist: https://www.youtube.com/watch?v=o7T-RG4GXR4&list=PLOjagPrE7-ZfNieK5cx0LAyJOgyiHoYte
%%%%%%%%%%Code%%%%%%%%%%%%%%%%
# python string
# using single quotation marks
a = 'Guangshu Coder'
print(a)
# using Double Quotation marks
a = "Guangshu Coder"
print(a)
# Multiline String
# using three double quotes
a = """
Guangshu Coder
Learn Code with me"""
print(a)
# using three single quotes
a = '''
Guangshu Coder
Learn Code with me'''
print(a)
# String Slicing
x = "Guangshu Coder"
print(x[2:5])
# Slicing from start
print(x[:5])
# slicing to end
print(x[2:])
# negative indexing
print(x[-5:-2])
# Modify String
a = "Guangshu Coder"
# upper() method returns the string in upper case:
print(a.upper())
# lower() method returns the string in lower case:
print(a.lower())
# strip() method removes any whitespace from beginning or the end
print(a.strip())
# replace() method replaces a string with another string:
print(a.replace("G", "H"))
# split() method splits string into substrings if it finds instances of the separator.
print(a.split("s"))

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Python String. String Functions Python code with example. Python Complete Course Video # 8», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.