我目前正在尝试制作一个登录系统,只是为了学习一些更高级的python脚本。在
最初,我使用.txt文件来保存所有信息,但结果却一团糟而且不安全。在
完成第一组脚本后,我决定尝试将信息保存到数据库文件中。我已经知道了如何从表中读取数据,但结果却是[(''),]。在
这是一个问题,因为我需要使用原始数据与输入进行比较,而这不能用它周围的符号来完成。在
所以,我想知道是否可以将数据作为原始字符串读取,而不使用符号。我在主项目的一个单独的文件中这样做。文件内容如下:import sqlite3 as sql
con = sql.connect(r"E:\Users.db")
c = con.cursor()
con.row_factory = sql.Row
username = input("What is your username: ")
readdata = input("Select the message you wish to read: ")
c.execute("SELECT * FROM Mail WHERE (Subject LIKE '"+readdata+"') AND (Recipient LIKE '"+username+"')")
component = c.fetchall()
for row in component:
c.execute("SELECT Recipient FROM Mail WHERE (Subject LIKE '"+readdata+"') AND (Recipient LIKE '"+username+"')")
rc = list(c.fetchall())
rec = str(rc)
c.execute("SELECT Sender FROM Mail WHERE (Subject LIKE '"+readdata+"') AND (Recipient LIKE '"+username+"')")
snt = list(c.fetchall())
sent = str(snt)
c.execute("SELECT Subject FROM Mail WHERE (Subject LIKE '"+readdata+"') AND (Recipient LIKE '"+username+"')")
sbject = list(c.fetchall())
subject = str(sbject)
c.execute("SELECT Message FROM Mail WHERE (Subject LIKE '"+readdata+"') AND (Recipient LIKE '"+username+"')")
mg = list(c.fetchall())
msg = str(mg)
print()
print("Sender: " + sent)
print("Recipient: " + rec)
print("Subject: " + subject)
print()
print("Message: " + msg)
输出如下:
^{pr2}$
这是所有正确的数据,但我需要删除[(''),]以便进行比较。我使用的是python3.4.2。在