๐๐ญ๐ซ๐ข๐ง๐ ๐๐๐ง๐ข๐ฉ๐ฎ๐ฅ๐๐ญ๐ข๐จ๐ง ๐ข๐ง ๐๐ฒ๐ญ๐ก๐จ๐ง:
Strings in Python are immutable sequences of characters.
๐- ๐ฅ๐๐ง(): ๐๐๐ญ๐ฎ๐ซ๐ง๐ฌ ๐ญ๐ก๐ ๐ฅ๐๐ง๐ ๐ญ๐ก ๐จ๐ ๐ญ๐ก๐ ๐ฌ๐ญ๐ซ๐ข๐ง๐ .
my_string = "Hello"
length = len(my_string) # length will be 5
๐- ๐ฌ๐ญ๐ซ(): ๐๐จ๐ง๐ฏ๐๐ซ๐ญ๐ฌ ๐ง๐จ๐ง-๐ฌ๐ญ๐ซ๐ข๐ง๐ ๐๐๐ญ๐ ๐ญ๐ฒ๐ฉ๐๐ฌ ๐ข๐ง๐ญ๐จ ๐ฌ๐ญ๐ซ๐ข๐ง๐ ๐ฌ.
num = 123
str_num = str(num) # str_num will be "123"
๐- ๐ฅ๐จ๐ฐ๐๐ซ() ๐๐ง๐ ๐ฎ๐ฉ๐ฉ๐๐ซ(): ๐๐จ๐ง๐ฏ๐๐ซ๐ญ ๐ ๐ฌ๐ญ๐ซ๐ข๐ง๐ ๐ญ๐จ ๐ฅ๐จ๐ฐ๐๐ซ๐๐๐ฌ๐ ๐จ๐ซ ๐ฎ๐ฉ๐ฉ๐๐ซ๐๐๐ฌ๐.
my_string = "Hello"
lower_case = my_string.lower() # lower_case will be "hello"
upper_case = my_string.upper() # upper_case will be "HELLO"
๐- ๐ฌ๐ญ๐ซ๐ข๐ฉ(): ๐๐๐ฆ๐จ๐ฏ๐๐ฌ ๐ฅ๐๐๐๐ข๐ง๐ ๐๐ง๐ ๐ญ๐ซ๐๐ข๐ฅ๐ข๐ง๐ ๐ฐ๐ก๐ข๐ญ๐๐ฌ๐ฉ๐๐๐ ๐๐ซ๐จ๐ฆ ๐ ๐ฌ๐ญ๐ซ๐ข๐ง๐ .
my_string = " Hello "
stripped_string = my_string.strip() # stripped_string will be "Hello"
๐- ๐ฌ๐ฉ๐ฅ๐ข๐ญ(): ๐๐ฉ๐ฅ๐ข๐ญ๐ฌ ๐ ๐ฌ๐ญ๐ซ๐ข๐ง๐ ๐ข๐ง๐ญ๐จ ๐ ๐ฅ๐ข๐ฌ๐ญ ๐จ๐ ๐ฌ๐ฎ๐๐ฌ๐ญ๐ซ๐ข๐ง๐ ๐ฌ ๐๐๐ฌ๐๐ ๐จ๐ง ๐ ๐๐๐ฅ๐ข๐ฆ๐ข๐ญ๐๐ซ.
my_string = "apple,banana,orange"
fruits = my_string.split(",") # fruits will be ["apple", "banana", "orange"]
๐- ๐ฃ๐จ๐ข๐ง(): ๐๐จ๐ข๐ง๐ฌ ๐ญ๐ก๐ ๐๐ฅ๐๐ฆ๐๐ง๐ญ๐ฌ ๐จ๐ ๐ ๐ฅ๐ข๐ฌ๐ญ ๐ข๐ง๐ญ๐จ ๐ ๐ฌ๐ข๐ง๐ ๐ฅ๐ ๐ฌ๐ญ๐ซ๐ข๐ง๐ ๐ฎ๐ฌ๐ข๐ง๐ ๐ ๐ฌ๐ฉ๐๐๐ข๐๐ข๐๐ ๐ฌ๐๐ฉ๐๐ซ๐๐ญ๐จ๐ซ.
fruits = ["apple", "banana", "orange"]
my_string = ",".join(fruits) # my_string will be "apple,banana,orange"
๐- ๐๐ข๐ง๐() ๐๐ง๐ ๐ข๐ง๐๐๐ฑ(): ๐๐๐๐ซ๐๐ก ๐๐จ๐ซ ๐ ๐ฌ๐ฎ๐๐ฌ๐ญ๐ซ๐ข๐ง๐ ๐ฐ๐ข๐ญ๐ก๐ข๐ง ๐ ๐ฌ๐ญ๐ซ๐ข๐ง๐ ๐๐ง๐ ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐ข๐ญ๐ฌ ๐ข๐ง๐๐๐ฑ.
my_string = "Hello, world!"
index1 = my_string.find("world") # index1 will be 7
index2 = my_string.index("world") # index2 will also be 7
๐- ๐ซ๐๐ฉ๐ฅ๐๐๐(): ๐๐๐ฉ๐ฅ๐๐๐๐ฌ ๐จ๐๐๐ฎ๐ซ๐ซ๐๐ง๐๐๐ฌ ๐จ๐ ๐ ๐ฌ๐ฎ๐๐ฌ๐ญ๐ซ๐ข๐ง๐ ๐ฐ๐ข๐ญ๐ก ๐๐ง๐จ๐ญ๐ก๐๐ซ ๐ฌ๐ฎ๐๐ฌ๐ญ๐ซ๐ข๐ง๐ .
my_string = "Hello, world!"
new_string = my_string.replace("world", "Python") # new_string will be "Hello, Python!"
๐- ๐ฌ๐ญ๐๐ซ๐ญ๐ฌ๐ฐ๐ข๐ญ๐ก() ๐๐ง๐ ๐๐ง๐๐ฌ๐ฐ๐ข๐ญ๐ก(): ๐๐ก๐๐๐ค๐ฌ ๐ข๐ ๐ ๐ฌ๐ญ๐ซ๐ข๐ง๐ ๐ฌ๐ญ๐๐ซ๐ญ๐ฌ ๐จ๐ซ ๐๐ง๐๐ฌ ๐ฐ๐ข๐ญ๐ก ๐ ๐ฌ๐ฉ๐๐๐ข๐๐ข๐๐ ๐ฌ๐ฎ๐๐ฌ๐ญ๐ซ๐ข๐ง๐ .
my_string = "Hello, world!"
starts_with_hello = my_string.startswith("Hello") # True
ends_with_world = my_string.endswith("world") # False
๐๐- ๐๐จ๐ฎ๐ง๐ญ(): ๐๐จ๐ฎ๐ง๐ญ๐ฌ ๐ญ๐ก๐ ๐จ๐๐๐ฎ๐ซ๐ซ๐๐ง๐๐๐ฌ ๐จ๐ ๐ ๐ฌ๐ฎ๐๐ฌ๐ญ๐ซ๐ข๐ง๐ ๐ข๐ง ๐ ๐ฌ๐ญ๐ซ๐ข๐ง๐ .
my_string = "apple, banana, orange, banana"
count = my_string.count("banana") # count will be 2
Python Free Resources
๐๐
https://whatsapp.com/channel/0029VaiM08SDuMRaGKd9Wv0L
Hope you'll like it
Like this post if you need more resources like this ๐โค๏ธ
Post #511
3.12K
- ๐ 4
- โค 1