Python TypeError,给出了一个参数六. [英] Python TypeError, one argument six given.

查看:43
本文介绍了Python TypeError,给出了一个参数六.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,正如你们所知,我正在尝试收集 x、y 坐标,我正在研究保存功能以将 x、y 保存到文本文件中.这是我得到的

Alright I am trying to gather x, y coordinates as you all know and I am working on the save feature to save the x, y's to a text file. here is what I got

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)

知道如何解决这个问题吗?

Any idea how to fix this?

推荐答案

.write 只带一个参数,先格式化字符串:

.write only takes one argument, format the string first:

outFile.write("Coordinate file: \n {} {} \n {} {}".format(x1, y1, x2, y2))

这篇关于Python TypeError,给出了一个参数六.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆