好吧我正在尝试收集你所知道的x,y坐标,我正在研究保存功能,将x,y保存到文本文件中。这是我得到的
x1 = raw_input("What is x1: ")
y1 = raw_input("What is y1: ")
x2 = raw_input("what is x2: ")
y2 = raw_input("what is y2: ")
outFile = open("c:\\users\zilvarael\Desktop\coord_man.txt", "wt")
outFile.write("Coordinate file: \n", x1, y1, "\n", x2, y2)
以下是我面临的错误:
outFile.write("Coordinate file: \n", x1, y1, "\n", x2, y2)
TypeError: function takes exactly 1 argument (6 given)
知道如何解决这个问题吗?
答案 0 :(得分:2)
.write
只接受一个参数,首先格式化字符串:
outFile.write("Coordinate file: \n {} {} \n {} {}".format(x1, y1, x2, y2))