hausaufgabe--python 29- File 2

本文汇总了多种文件操作技巧,包括获取文件名并保存用户输入、打印特定路径下的文件指定行数、比较两个文件的差异及在文件中查找并替换指定词汇等内容。

 

 

000

get the files name and save what the users input _ with ':w' to save and quit 

 

 

 

running result:

 

defect: no pop up message for user to input the text.

 

standar:

 

 

001

to print the specific path file with defined lines 

 

 running result:

 

another solution:

 

 

002

to print specific lines for a file :

 

 

running result:

 

 

 

 another solution:

 

running result:

 

 

 

 

 

003

 to compare 2 files difference

 

running result:

 

 

004

to find a word and replace with another one in a file:

 

 

 

running result:

 

 

reffered:

http://bbs.fishc.com/forum.php?mod=viewthread&tid=45279&extra=page%3D1%26filter%3Dtypeid%26typeid%3D403

find and replace a word in a string:

http://blog.youkuaiyun.com/u011860731/article/details/46956953

http://blog.youkuaiyun.com/seetheworld518/article/details/47346143

open a unicode txt:

http://www.cnblogs.com/mengyu/p/6638975.html

 

转载于:https://www.cnblogs.com/Shareishappy/p/7148284.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值