【发布时间】:2020-01-06 10:38:10
【问题描述】:
我想将值存储在文件中,以便它们保持其属性。请在下面查看我的代码的 sn-p。
if selection == ("1"):
newUserID = input ("Please enter their 3 digit ID: ")
#check the user has put in numbers and at least 3 digits
newUserName = input("Please enter the employees name: ")
#check for string not number. Has to be exactly their name
newUserPassword = input ("Please enter their Clocking in password: ")
count = count + 1
uniqueUserID = (newUserID, newUserName, newUserPassword, count)
uniqueUserID = str(uniqueUserID)
file.write(uniqueUserID)
file.close()
我正在使用 Python,还需要将用户的输入存储在一个“count”变量中,以跟踪有多少用户。
谢谢。
【问题讨论】:
-
您可能想开始研究使用数据库
-
我将如何使用 python 做到这一点?抱歉 - 我对编码很陌生。
-
您可以使用本地 SQLite 数据库。您将能够创建一个名为 users 的表,其中包含 id、用户名和密码作为字段。作为介绍,我建议阅读这篇文章:datatofish.com/create-database-python-using-sqlite3
-
我可以使用微软访问吗?
-
是的,这也行。
标签: python