我有一個大的文件,只會發佈精簡版一塊吧:如何讀取文件的特定部分
World population in thousands
Source: United Nations, DEMOBASE
Country/ISO country code/UN Code/Population 1950/Population 2012
----------------------------------------------------------------
Afghanistan/AF/4/8151/33397
Albania/AL/8/1215/3227
Algeria/DZ/12/8753/36486
American Samoa/AS/16/19/71
Andorra/AD/20/6/88
我的問題是我怎麼讀5個第一排,就在信息有關國家的信息就開始了。
我試着像成才:
file=open("wordpop.txt","r")
for i in range[0:5]:
rows = file.read()
print(rows)
'因爲我在範圍內( 5)' – millimoose 2013-02-14 17:07:48