jagomart
digital resources
picture1_Python Read Text From Pdf 191790 | Python Note 4


 134x       Filetype PDF       File size 0.27 MB       Source: www.wpedu.sch.lk


File: Python Read Text From Pdf 191790 | Python Note 4
python text file handling program 1 open file fo open foo txt wb output print name of the file fo name name of the file foo txt print close the ...

icon picture PDF Filetype PDF | Posted on 04 Feb 2023 | 2 years ago
Partial capture of text on file.
                                  Python text file handling 
            Program 1 
            #open file  
            fo=open("foo.txt","wb")                                      Output 
            print ("Name of the file: ", fo.name)             Name of the file:  foo.txt 
            print ("Close the file: ", fo.closed)             Close the file:  False 
            print ("Openning mode: ", fo.mode)                Openning mode:  wb 
            #close file                                       Close the file:  True 
                                                               
            fo.close() 
            print ("Close the file: ", fo.closed) 
             
            Program 2                                                    Output 
            #open file for writting                            file written successfully 
            fo=open("myfile.txt","w");                         Yeah it’s great 
            #write to file 
            fo.write ("Python is a great language. \nYeah it’s great"); 
            print ("file written successfully"); 
            fo.close(); 
             
             
             
             
            Program 3 
            #read and print a text file  
            fo=open("myfile.txt","r");                                 Output 
            str=fo.read();                                  Python is a great language. 
            print(str); 
            print(fo.tell()); 
            fo.close(); 
             
            Program 4 
            #print current working directory 
            import os                                                   Output 
            print(os.getcwd());                              E:\Nayana\pascal prac 
             
             
            Program 5 
            #read and print a text file  
            fo=open("myfile.txt","r");                                  Output 
            str=fo.read();                                   Python is a great language. 
            print(str); 
            #See the position                                27 
            print(fo.tell()); 
            fo.close(); 
The words contained in this file might help you see if this file matches what you are looking for:

...Python text file handling program open fo foo txt wb output print name of the close closed false openning mode true for writting written successfully myfile w yeah it s great write to is a language nyeah read and r str tell current working directory import os getcwd e nayana pascal prac see position...

no reviews yet
Please Login to review.