gpt4 book ai didi

Python 方法不会出现在用户定义的函数中

转载 作者:行者123 更新时间:2023-12-01 07:48:05 24 4
gpt4 key购买 nike

创建用户定义函数时,内置方法不会作为选项弹出。

在文件的主体中,方法显示没有问题。只有当您创建函数时它们才不会显​​示。

def strip_punctuation(astring):
#punctuation_chars = ["'", '"', ",", ".", "!", ":", ";", '#', '@']
astring.replace()
return (astring)

# Main file
my_string = "Word's!"
my_string.replace()

我希望 VS Code 中的用户定义函数以及函数外部都有相同的行为。

最佳答案

如果您使用类型注释重写代码,您应该得到您想要的:

def strip_punctuation(astring: str) -> str:
astring.replace()
return astring

关于Python 方法不会出现在用户定义的函数中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56350507/

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