Storing and parsing Python objects in files : Text file : File PYTHON TUTORIALS


PYTHON TUTORIALS » File » Text file »

 

Storing and parsing Python objects in files


X, Y, Z = 434445                      
S = 'Spam'                                
D = {'a'1'b'2
L = [123

F = open('datafile.txt', 'w')             
F.write(S + 'n')                         
F.write('%s,%s,%sn' % (X, Y, Z))         
F.write(str(L'$' + str(D'n')     
F.close(  ) 

bytes = open('datafile.txt').read(  )     
print bytes 


X, Y, Z = 434445                      
S = 'Spam'                                
D = {'a'1'b'2
L = [123

F = open('datafile.txt', 'w')             
F.write(S + 'n')                         
F.write('%s,%s,%sn' % (X, Y, Z))          
F.write(str(L'$' + str(D'n')      
F.close(  )



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo File
» Text file