...

Web Technologies - PYTHON

Back to Course

Lesson Description


Lession - #267 Python Strings


A string in Python is a sequence of characters. It is a derived data type. Strings are immutable. This means that once defined, they can't be changed. Numerous Python methods, for example, replace , join , or split modify strings.

In the same way as other famous programming languages, strings in Python are array of bytes addressing unicode characters. Be that as it may, Python doesn't have a person information type, a solitary person is basically a string with a length of 1. Square brackets can be utilized to get to elements of the string.

Let's see a example



# defining strings in Python
# all of the following are equivalent
my_string = 'Hello'
print(my_string>
my_string = "Hello" print(my_string>
my_string = '''Hello''' print(my_string>
# triple quotes string can extend multiple lines my_string = """Hello, welcome to the world of Python""" print(my_string>

Output


Try it here

python read file

To read a text record in Python, you follow these means: First, open a text document for perusing by utilizing the open(>
work. Second, read text from the text document utilizing the record read(>
, readline(>
, or readlines(>
technique for the record object.