在Python f-strings中,使用{}的方法是众所周知的,它可以执行代码并将结果以字符串格式呈现(一些教程在这里)。但是,表达式末尾的“=”表示什么意思?
Python f-strings中的{}用于替换值。 =后面的表达式计算要替换的值。
log_file = open("log_aug_19.txt", "w")
console_error = '...stuff...' # the real code generates it with regex
log_file.write(f'{console_error=}')