Python 打印查询结果时遇到问题
我看到一个建议,建议将其更改为“,”。join([None]),但我尝试了,但没有成功。确保已创建游标对象:Python 打印查询结果时遇到问题,python,sql,Python,Sql,我看到一个建议,建议将其更改为“,”。join([None]),但我尝试了,但没有成功。确保已创建游标对象: query = c.execute('SELECT * FROM Patients') resultset = c.fetchall() if not resultset: print("Sorry, the last name you entered does not match any patients " "in the hospital.") #i
query = c.execute('SELECT * FROM Patients')
resultset = c.fetchall()
if not resultset:
print("Sorry, the last name you entered does not match any patients "
"in the hospital.") #if there are no results this is printed
else:
for result in resultset:
result = ' '.join(result)
print("\n\t", result)
我被提示同样的错误,说,寻找字符串类型时,没有找到任何类型。
c = sqlite3.connect('databasename.db').cursor()
query = list(c.execute('SELECT * FROM Patients'))
#now, you can check query:
if not query :
print("Sorry, the last name you entered does not match any patients "
"in the hospital.") #if there are no results this is printed
else:
for val in [' '.join(i) for i in query]:
print "\n\t{}".format(val)