我是新手,也是 Python 的新手。 我想知道在 print(f'Column names are {"-".join(row)}')
中的 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.')