【发布时间】:2015-05-05 01:33:36
【问题描述】:
所以我必须编写一个程序来读取包含地震数据的csv 文件,然后仅从文件中获取纬度和经度并将其映射到 Python 3 中的海龟屏幕。
这是CSV file
我的程序:
import turtle
def drawQuakes():
filename = input("Please enter the quake file: ")
readfile = open(filename, "r")
readlines = readfile.read()
start = readlines.find("type")
g = readlines[start]
Type = g.split(",")
tracy = turtle.Turtle()
tracy.up()
for points in Type:
print(points)
x = float(Type[1])
y = float(Type[2])
tracy.goto(x,y)
tracy.write(".")
drawQuakes()
我知道这个程序相当简单,但我一直收到这个错误:
x = float(Type[1])IndexError: list index out of range
【问题讨论】:
标签: python format turtle-graphics