【发布时间】:2017-02-07 23:53:22
【问题描述】:
这是我第一次发帖。我对 Python 真的很陌生,几周前刚开始上课。我正在尝试读取一个包含 (x,y) 坐标的 Excel 文件,在读取它之后,我将不得不相应地绘制点。
我为我的点创建了一个函数,读取文件并将它们分成两个列表 x[] 和 y[]。我无法将 x[] 和 y[] 中的 X、Y 值传递给我的 dot() 函数。
我在网上搜索过类似的问题,但没有运气,我确信这是因为我对编程缺乏经验。希望能得到大家的一些建议。
我已经在下面发布了我的代码。
非常感谢。
import turtle
def dot(x, y):
t = turtle.Turtle()
t.pensize(2)
t.up()
t.goto(x, y)
t.color("red")
t.down()
t.begin_fill()
t.circle(25)
t.color("red")
t.end_fill()
turtle.done()
def a():
x, y = [], []
handle = open("SineWave.csv")
for line in handle:
line = line.rstrip()
line = line.split(",")
x.append(line[0])
y.append(line[1])
x = [int(n) for n in x]
y = [int(n) for n in y]
i = 0
while i < len(x):
print (x[i])
i += 1
def b():
x, y = [], []
handle = open("SineWave.csv")
for line in handle:
line = line.rstrip()
line = line.split(",")
x.append(line[0])
y.append(line[1])
x = [int(n) for n in x]
y = [int(n) for n in y]
i = 0
while i < len(y):
print(y[i])
i += 1
dot(a(),b())
【问题讨论】:
标签: python excel turtle-graphics