Python-将变量输出连接到字符串



我正在尝试将sql输出的输出连接到如下字符串:

dwh_cur.execute("""select name from sales where id = 123""")
name = dwh_cur.fetchone()[0]
a = print(name)
b = str(a) + " is the name of the agent"
print(b)

以上返回

None is the name of the agent

预期输出:

Steve is the name of the agent
a = print(name)

return None

尝试:

b = "{} is the name of the agent".format(name)

最新更新