鱼C论坛

 找回密码
 立即注册
查看: 1221|回复: 1

求助大佬pyehon中class的用法

[复制链接]
发表于 2021-10-23 22:01:43 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
大佬,我想问一下这个代码哪里有问题

class Solution:

            def romanToInt(self, s: str) -> int:
                          
                        代码

        def longestCommonPrefix(self, strs: list[str]) -> str:

                        代码

报错:
Traceback (most recent call last):
  File "C:\Users\mate\AppData\Roaming\JetBrains\PyCharmCE2021.2\scratches\second.py", line 1, in <module>
    class Solution:
  File "C:\Users\mate\AppData\Roaming\JetBrains\PyCharmCE2021.2\scratches\second.py", line 28, in Solution
    def longestCommonPrefix(self, strs: list[str]) -> str:
TypeError: 'type' object is not subscriptable
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-10-23 22:15:50 | 显示全部楼层
  1. def longestCommonPrefix(self, strs: list[str]) -> str;
复制代码

把 str 换下,可能是命名冲突了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-3-29 16:33

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表