print(f"")与print('' '') 有什么不同?

加入f之后,可以直接在字符串中填入需要替换的字符:

print('# text lines: {len(lines)}')
print(f'# text lines: {len(lines)}')

output:

# text lines: {len(lines)}
# text lines: 3221

posted @ 2021-08-23 16:36  zae  阅读(638)  评论(0编辑  收藏  举报