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

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

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

10-07 19:00
查看更多