gpt4 book ai didi

python - 键入注释样式(空格或不空格)

转载 作者:太空宇宙 更新时间:2023-11-03 14:05:29 24 4
gpt4 key购买 nike

具有以下功能:

def foo(x=1):
print(x)

PEP 8中有明确说明当用于指示关键字参数或默认参数值时,不应在 = 符号周围使用空格。

如果我们想对 x 参数进行类型注释。我们应该怎么做?

def foo(x:int=1):
def foo(x: int=1):
def foo(x: int = 1):

有没有更好的方法?或者更好的是,它是否在某些 PEP 中指定?在 PEP 484 中没有找到.

最佳答案

The examples in PEP 484全部使用

def foo(x: int = 1):

关于python - 键入注释样式(空格或不空格),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43914201/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com