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

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

  •  
  •   nextone · 2024-09-27 17:00:30 +08:00 · 1706 次点击
    这是一个创建于 365 天前的主题,其中的信息可能已经有所发展或是发生改变。
    def convert_snake(camel):
        convert_chars = ""
        for char in camel:
            if char.isupper():
    convert_snake("littleTest")
    

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

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