open("","r")与open("","rb")的效率区别

fd = open("C:\Users\william\Desktop\dup_file - Copy (3).txt","r")
for i in fd:
print i

耗时 25.6074296742s

 

fd = open("C:\Users\william\Desktop\dup_file - Copy (3).txt","rb")
for i in fd:
print i

耗时 60.840389834

有文章提到说在windows系统中,要加上rb,否则代码会很慢,但通过上面,发现rb明显更慢。

posted @ 2016-11-08 14:20  guohuino2  阅读(972)  评论(0编辑  收藏  举报