python-如何以字符串格式获取字符串的值

问题描述 投票:-2回答:1

请参阅下面的示例以了解问题。

a1 = 5
print("a{}".format(1))

output: a1

我希望输出为a1的值,即5

python-3.x string-formatting
1个回答
0
投票

您的代码中有错别字:

print("{}".format(a1))
© www.soinside.com 2019 - 2024. All rights reserved.