Files
python/pythonProject/格式化字符串/format/2.py
T
2026-05-18 17:58:02 +08:00

8 lines
269 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# format还可以根据关键词引用,这种方式就不需要考虑参数在format内的哪个位置,只根据关键词引用
str = '''
窗前明月{a},
疑是地上{b},
举头望明{c},
低头思故{d}
'''
print(str.format(a='光',b='霜',c='月',d='乡'))