V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
nextone
V2EX  ›  Visual Studio Code

vs code 的智能提示补全不行呀

  •  
  •   nextone · 7 天前 · 716 次点击
    def convert_snake(camel):
        convert_chars = ""
        for char in camel:
            if char.isupper():
    convert_snake("littleTest")
    

    当我输入 if char.isup 时,vs code 不能智能提示字符串的方法,这也太不智能了吧

    7 条回复
    FishBear
        1
    FishBear  
       7 天前
    可以试试 cursor 虽然我现在没付费
    DOLLOR
        2
    DOLLOR  
       7 天前
    定义函数的时候,你把 camel 的类型补上啊,就像这样:
    def convert_snake(camel: str)
    不然它不知道 camel 的类型,也就没法推断 char 类型,也就没法给你补全 char.下面的方法。
    strickczq
        3
    strickczq  
       7 天前
    type hints 是个好东西
    nextone
        4
    nextone  
    OP
       7 天前
    @DOLLOR 但是其他的编辑器不加类型提示也可以
    xuld
        5
    xuld  
       7 天前   ❤️ 1
    如果你在别的地方有 convert_snake(1111),你会不会骂它提示出 string 的方法是 bug
    Wilson233
        6
    Wilson233  
       5 天前
    试了下,PyCharm 在存在代码 `convert_snake("littleTest")` 的情况下会提示字符串方法,如果存在的是 `convert_snake(1111)` 就不会提示。感觉还挺合理🤔
    nextone
        7
    nextone  
    OP
       4 天前
    @Wilson233 这些细节上,PyCharm 还是优于 vs code 呀
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1541 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 00:35 · PVG 08:35 · LAX 17:35 · JFK 20:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.