python: readline() and read()
[root@mysql Scripts]# ./file1.py
If we give print han1 Then output would be
File is open only once
Actual output should be like this so use han1.readline() [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
If you use han1.readline(10) Then it will print next 10 characters as in upper line already pritn upto first
I am a bes
If you use again han1.readline(10) then it will print next 10 character untill didnt get next line t player
If you use han1.readline(15) then again print next 15 characters I am the best p
------------------now start read()--------------------
Now use han1.read() layer
I am best player
I am an best player
I am a best player
I am a best player
I am a best player
I am a best player
I am a best player
I am a best player
This will print only Blank lines han1.read(20)....
because file completly open by last command now nothing to read in file so only blank spaces...:)
If we give print han1 Then output would be
File is open only once
Actual output should be like this so use han1.readline() [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
If you use han1.readline(10) Then it will print next 10 characters as in upper line already pritn upto first
I am a bes
If you use again han1.readline(10) then it will print next 10 character untill didnt get next line t player
If you use han1.readline(15) then again print next 15 characters I am the best p
------------------now start read()--------------------
Now use han1.read() layer
I am best player
I am an best player
I am a best player
I am a best player
I am a best player
I am a best player
I am a best player
I am a best player
This will print only Blank lines han1.read(20)....
because file completly open by last command now nothing to read in file so only blank spaces...:)
Comments
Post a Comment