嗨,我正在尝试将sqlite文件打印为可读格式。我正在使用dionea Honenet的python脚本。每次运行脚本时都会遇到此错误:
File "./readlogsqltree.py", line 268, in print_logins
login['login_password']))
TypeError: unsupported format string passed to bytes.__format__
login['login_password']是一个取自select语句的变量。下面是正在调用的函数:
def print_logins(cursor, connection, indent):
r = cursor.execute("""
SELECT
login_username,
login_password
FROM
logins
WHERE connection = ?""", (connection, ))
logins = resolve_result(r)
for login in logins:
print("{:s} login - user:'{:s}' password:'{:s}'".format(
' ' * indent,
login['login_username'],
login['login_password']))
解析结果函数:
def resolve_result(resultcursor):
names = [resultcursor.description[x][0] for x in range(len(resultcursor.description))]
resolvedresult = [ dict(zip(names, i)) for i in resultcursor]
return resolvedresult
光标:
def print_db(opts, args):
dbpath = 'logsql.sqlite'
if len(args) >= 1:
dbpath = args[0]
print("using database located at {0}".format(dbpath))
dbh = sqlite3.connect(dbpath)
cursor = dbh.cursor()
对于Python 3,在调用^{} 之前使用^{} 解码字符串
我在将某个python2脚本转换为python3时遇到此错误:
解决方案是使用
base64.b64encode(image_buffer.getvalue()).decode()
,而不是base64.b64encode(image_buffer.getvalue())
中的this post。相关问题 更多 >
编程相关推荐