Quantcast

如何在文件的开头添加内容?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

如何在文件的开头添加内容?

kun xu-3
以append模式打开文件,追加的内容都在文件末尾,如果我想从文件头开始追加内容,并不刷掉原来的数据,应该如何做?
 
robot.txt:
---------------------------------分割线内为robot.txt实际内容------------------------------
222
333
444
555
---------------------------------分割线内为robot.txt实际内容------------------------------
 
 
现在想在文件头中追加"111",应该怎么做使robot.txt变成:
 
robot.txt:
---------------------------------分割线内为robot.txt实际内容------------------------------
111
222
333
444
555
---------------------------------分割线内为robot.txt实际内容------------------------------
 
 
 
 
 

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Loading...