[英]I keep getting this error in python3 “TypeError: an integer is required (got type str)”
so basically i have been working on a project that makes a login and signup system with python3 using tkinter ive come to the point where i have to save the things inputed into a file with open() but it keeps giving me this error所以基本上我一直在研究一个项目,该项目使用 python3 使用 tkinter 进行登录和注册系统,我已经到了必须使用open()将输入的内容保存到文件中的地步,但它一直给我这个错误
File "C:\Users\Kirill Rodionov\AppData\Local\atom\app-1.45.0\login.py", line 19, in storeData
passwordFile = open("Passwords.txt", "a")
TypeError: an integer is required (got type str)
this is my code这是我的代码
from tkinter import *
from os import *
nameFile = open("Names.txt", O_APPEND)
passwordFile = open("Passwords.txt", O_APPEND)
def SignUp():
def storeData():
name = signupNameEntry.get()
password = signupPasswordEntry.get()
rpassword = signupRPasswordEntry.get()
print(name)
print(password)
print(rpassword)
print(type(name))
print(type(password))
if password == rpassword:
print("passwords match")
nameFile = open("Names.txt", "a")
passwordFile = open("Passwords.txt", "a")
passwordFile.write(password)
nameFile.write(name)
passwordFile.close()
nameFile.close()
else:
print("passwords don't match")
signup = Toplevel()
signup.title("Sign Up")
Label(signup, text="Name", pady=5, padx=5).grid(row=1, column=1)
Label(signup, text="Password", pady=5, padx=5).grid(row=2, column=1)
Label(signup, text="Repeat\nPassword").grid(row=3, column=1)
signupNameEntry = Entry(signup)
signupNameEntry.grid(row=1, column=2)
signupPasswordEntry = Entry(signup)
signupPasswordEntry.grid(row=2, column=2)
signupRPasswordEntry = Entry(signup)
signupRPasswordEntry.grid(row=3, column=2)
signupButton = Button(signup, text="Sign Up", command=storeData, pady=5, padx=5).grid(row=4, column=2)
signup.mainloop()
the other part is the main loop i hope you get the code is the main loop i cant post the whole code because it says "your post is mostly code" btw im new to stackoverflow另一部分是主循环我希望你得到代码是主循环我不能发布整个代码因为它说“你的帖子主要是代码”顺便说一句我是stackoverflow的新手
Are you using from os import *
?你在使用from os import *
吗? In this case, it may be trying to use os.open
.在这种情况下,它可能会尝试使用os.open
。 See An integer is required?请参阅需要 integer 吗? open() . 打开() 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.