我是 Python 新手,我正在从教程中学习,这里有这一行假设从 .csv 文件中读取并跳过第一行(标题):
data = open("banklist.csv", "r").readlines()[1:]
for entry in data:
#do some stuffs
问题是,它甚至没有进入循环。删除 open 语句中的 [1:] 并添加打印数据,我发现 csv 似乎被读取为一大行,而删除标题则删除了所有内容:
["First National Bank also operating as The National Bank of El Paso,Edinburg,TX,14318,13-Sep-13,18-Sep-13\rThe Community's Bank,Bridgeport,CT,57041,13-Sep-13,17-Sep-13\rSunrise Bank of Arizona,Phoenix,AZ,34707,23-Aug-13,11-Sep-13\rCommunity South Bank,Parsons,TN,19849,23-Aug-13,5-Sep-13\rBank of Wausau,Wausau,WI,35016,9-Aug-13,4-Sep-13\rFirst Community Bank of Southwest Florida (also operating as Community Bank of Cape Coral),Fort Myers,FL,34943,2-Aug-13,26-Aug-13\rMountain National Bank,Sevierville,TN,34789,7-Jun-13,26-Aug-13\r1st Commerce Bank,North Las Vegas,NV,58358,6-Jun-13,26-Aug-13\rBanks of Wisconsin d/b/a Bank of Kenosha,Kenosha,WI,35386,31-May-13,12-Jul-13\rCentral Arizona Bank,Scottsdale,AZ,34527,14-May-13,26-Aug-13\rSunrise Bank,Valdosta,GA,58185,10-May-13,12-Jul-13\rPisgah Community Bank,Asheville,NC,58701,10-May-13,26-Aug-13\rDouglas County Bank,Douglasville,GA,21649,26-Apr-13,26-Aug-13\rParkway Bank,Lenoir,NC,57158,26-Apr-13,26-Aug-13\rChipola Community Bank,Marianna,FL,58034,19-Apr-13,12-Jul-13\rHeritage Bank of North Florida,Orange Park,FL,26680,19-Apr-13,26-Aug-13\rFirst Federal Bank,Lexington,KY,29594,19-Apr-13,12-Jul-13"]
我该怎么做?