小编Kra*_*sA4的帖子

'f' 在 Python 中的字符串之前是什么意思?

我是新来的,也是 Python 的新手。我不知道是什么fprint(f'Column names are {"-".join(row)}')做我试着删除它,然后“列名是{‘ - ’加入(行)}”成为普通的字符串

你能告诉我什么f叫,所以我可以谷歌了解更多信息吗?谢谢你们。

import csv

with open('CSV_test.txt') as csv_file: 
    csv_reader = csv.reader(csv_file, delimiter=',')
    line_count = 0
    for row in csv_reader:
        if line_count == 0:
            print(f'Column names are {"-".join(row)}')
            line_count += 1
        else:
            print(f'\t{row[0]} works in the {row[1]} '
                  f'department, and was born in {row[2]}.')
            line_count += 1
    print(f'Processed {line_count} lines.')
Run Code Online (Sandbox Code Playgroud)

python f-string

2
推荐指数
3
解决办法
5131
查看次数

标签 统计

f-string ×1

python ×1