Wednesday, November 19, 2008

Print to a file,a simple log system

There is many of log system in this time.Use python we can create a very simple log system.The way is use print function and >> operator.
Here is the example code:
#python code
>>log=open('c:/log.txt','a') #open a file to log the message
>>print>>log,"This is log information" #then we put the log information to a file
>>log.close() # don't forget close the file

No comments: