Python 字符串中的双括号

Python 字符串中的双括号,第1张

Python 字符串中的双括号
variable = 1

print('{}')
# output: {}

print('{{}}')
# output: {{}}

print(f'{{}}')
# output: {}

print(f'{variable}')
# output: 1

print(f'{{variable}}')
# output: {variable}

print('{}'.format(variable))
# output: 1

print('{{}}'.format(variable))
# output: {}

print('{variable}'.format(variable))
# output: error

print('{{variable}}'.format(variable))
# output: {variable}

如果我的陈述存在疏漏还请不吝赐教感激不尽
如果觉得有用就请点个赞吧,创作动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5650735.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存