【发布时间】:2016-11-07 07:17:48
【问题描述】:
我有一个简单的问题。我在一个 txt 文件中有两个数字,我正在尝试创建一种方法,可以在我的代码中为 txt 文件中的这两个数字更改两个变量。
这是我的方法:
def loadCoords(cordX, cordY):
i=0;
f1 = open( 'continue.txt', "r")
f2 = open( 'continue.txt', "r")
f1.readline();
while i<2:
f2.readline();
i=i+1;
#already tested>>> cord=f.readline() xD
#also tried to put another names for the cordX and cordY here inside xD
cordY=f2;
cordX=f1;
return cordX;
return cordY;
这里是我调用方法的地方:
if evento.type == pygame.KEYDOWN:
if evento.key == pygame.K_a:
print('GAME BEGIN')
GAME_BEGIN = True
loadCoords(cordX,cordY);
有人可以帮忙吗?
【问题讨论】:
-
您遇到了什么错误?
-
没有人,它只是无法读取 f1 和 f2 文件,coordX 和 Y 打印 0 和 0 ,这是我在开始时声明的数字。