您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

用Python打印变量的非Python方法?

用Python打印变量的非Python方法?

唯一的其他方法是使用Python 2.6 + / 3.x.format()方法进行字符串格式化:

# dict must be passed by reference to .format()
print("{foo}, {bar}, {baz}").format(**locals())

或通过名称引用特定变量:

# Python 2.6
print("{0}, {1}, {2}").format(foo, bar, baz)

# Python 2.7/3.1+
print("{}, {}, {}").format(foo, bar, baz)
python 2022/1/1 18:45:39 有334人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶