简体   繁体   English

visual studio 代码中的建议在 python 中不起作用定义 function

[英]suggestion in visual studio code doesn't work in python define function

I'm programming in python我正在编程 python

例子

I'm making a function in Python using Visual Studio Code but the suggestions don't include string methods like replace() , lower() and strip() .我正在使用 Visual Studio Code 在 Python 中制作 function,但建议不包括字符串方法,如replace()lower()strip()

I don't know what is causing this issue and I tried every setting in Visual Studio Code.我不知道是什么导致了这个问题,我尝试了 Visual Studio Code 中的每个设置。 Can anyone tell me why it doesn't show the methods while other IDEs do?谁能告诉我为什么它不显示方法而其他 IDE 显示?

You could use text:str so that pylance knows text is String.您可以使用text:str以便 pylance 知道文本是字符串。

Your original code doesn't define the type of text .您的原始代码未定义text的类型。 It can be any type.它可以是任何类型。 Naturally, pylance can't give advice. pylance自然无法给出建议。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM