Python 猜数字

Python Guess the Number

(Python猜数字)

这个f是哪里来的?或者这个 f 是什么意思?

代码如下: guess = int(input(f 'Guess a number between 1 and {x}: '))

开头带有 'f' 的字符串称为 f 字符串。它是 python 3.6 的新功能之一。您可以在这些链接中阅读更多相关信息:

Tutorial on Python 3's f-strings

Official Documentation from python.org

那是一种称为 f-string 的表示,他们在 Python 3.6

中开始支持它们

https://realpython.com/python-f-strings/