filmov
tv
Read() Function in Python | Python built-in functions | Python tutorials for beginners

Показать описание
#Builtinfunction #ReadFunction #PythonTutorials
Read() Function in Python:
1. This is a built-in function, this function is used to handle the files.
2. This is used to read the data from the given file.
3. In python, the read() is avaiable 4 forms:
a). read()
b). read(n)
c). readline()
d). readlines()
a). read():
This furnction reads the entire data from the given file.
syntax:
read()
ex: to read entire data from a file:
print(d)
b). read(n):
This function is used to read the 'n' characters only
syntax:
read(n)
here, n is size .
ex: to read first 8 characters from a file:
print(d)
3. readline():
This function is used to read only one line
syntax:
readline()
ex: to read first line
print(a)
ex-2: to read first line
print(a)
print(b)
print(c)
d). readlines():
This function is used to read all lines from
a given file.
this funtions returns the result as list type.
ex: to read entire data from a file:
print(d)
for i in d:
print(i)
---------------------------------------------
Python tutorial for beginners| python programming language tutorial
Python basics | python tutorial for beginners | learn python programming from scratch
Python tutorial for beginners - learn python for machine learning and web development.
Python tutorial for beginners | python programming | learn python | great learning.
Python tutorial for beginners [full course] learn python for web development.
Read() Function in Python:
1. This is a built-in function, this function is used to handle the files.
2. This is used to read the data from the given file.
3. In python, the read() is avaiable 4 forms:
a). read()
b). read(n)
c). readline()
d). readlines()
a). read():
This furnction reads the entire data from the given file.
syntax:
read()
ex: to read entire data from a file:
print(d)
b). read(n):
This function is used to read the 'n' characters only
syntax:
read(n)
here, n is size .
ex: to read first 8 characters from a file:
print(d)
3. readline():
This function is used to read only one line
syntax:
readline()
ex: to read first line
print(a)
ex-2: to read first line
print(a)
print(b)
print(c)
d). readlines():
This function is used to read all lines from
a given file.
this funtions returns the result as list type.
ex: to read entire data from a file:
print(d)
for i in d:
print(i)
---------------------------------------------
Python tutorial for beginners| python programming language tutorial
Python basics | python tutorial for beginners | learn python programming from scratch
Python tutorial for beginners - learn python for machine learning and web development.
Python tutorial for beginners | python programming | learn python | great learning.
Python tutorial for beginners [full course] learn python for web development.