The print >> file Extension : Redirect : File PYTHON TUTORIALS


PYTHON TUTORIALS » File » Redirect »

 

The print >> file Extension


import sys 
temp = sys.stdout                     
sys.stdout = open('log.txt', 'a')     
print 'spam'                          
print 12
sys.stdout.close(  )                  
sys.stdout = temp                     

print 'back here'                     
print open('log.txt').read(  )



Leave a Comment / Note


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


PYTHON TUTORIALS

 Navioo File
» Redirect