Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“与”之间有区别吗;f";及;F";在Python字符串格式中?_Python_String_String Formatting - Fatal编程技术网

“与”之间有区别吗;f";及;F";在Python字符串格式中?

“与”之间有区别吗;f";及;F";在Python字符串格式中?,python,string,string-formatting,Python,String,String Formatting,为了在Python3.6+中格式化字符串,我通常使用小写的“f”选项来包含变量。例如: response=requests.get(f'{base\u url}/{endpoint}?fields={field\u list}') 我最近看到我的一个同事总是用大写字母“F”来代替。像这样: response=requests.get(F'{base\u url}/{endpoint}?fields={field\u list}') 小写字母“f”和大写字母“f”之间有区别吗?如果是,您什么时候

为了在Python3.6+中格式化字符串,我通常使用小写的“f”选项来包含变量。例如:

response=requests.get(f'{base\u url}/{endpoint}?fields={field\u list}')

我最近看到我的一个同事总是用大写字母“F”来代替。像这样:

response=requests.get(F'{base\u url}/{endpoint}?fields={field\u list}')


小写字母“f”和大写字母“f”之间有区别吗?如果是,您什么时候会使用它们?

如,一章中所述,两者都是可以接受的,不应该有所不同

在源代码中,f字符串是以字母“f”或“f”为前缀的字符串文本。本政治公众人物使用“f”的地方,也可以使用“f”。

如,章节中所述,两者都可以接受,并且不应有所不同


在源代码中,f字符串是以字母“f”或“f”为前缀的字符串文本。本政治公众人物使用“f”的地方,也可以使用“f”。

没有任何区别。请参阅Python文档中的定义

格式化字符串文字或f-string是前缀为“f”或“f”的字符串文字


没有进一步提到用于引入文字的特定字符。

没有任何区别。请参阅Python文档中的定义

格式化字符串文字或f-string是前缀为“f”或“f”的字符串文字


没有进一步提到用于引入文字的特定字符。

两者之间没有区别。为了更好地理解,您可以使用字符串格式

两者之间没有区别。为了更好地理解,您可以使用字符串格式

AFAIK,“F”和“F”之间没有区别。小写
F
更容易键入,因为它不需要按住Shift键。AFAIK,“F”和“F”之间没有区别。小写
F
更容易键入,因为它不需要按住Shift键。