随笔分类 - leetCode
摘要:代码 class Solution: def isValid(self, s: str) -> bool: while True: if '[]' in s: s = s.replace('[]', '') elif '{}' in s: s = s.replace('{}', '') elif
阅读全文
摘要:class Solution: def longestCommonPrefix(self, s) -> str: ''' 判断s是不是空,是空的话直接返回,不是空进入逻辑判断 :param s: :return: ''' if not s: return "" # 取list里的第一个字符,用这个去
阅读全文
摘要:Python中判断list是否为空有以下两种方式: 方式一: 1 list_temp = [] 2 if len(list_temp): 3 # 存在值即为真 4 else: 5 # list_temp是空的 方式二: 1 list_temp = [] 2 if list_temp: 3 # 存在值
阅读全文
摘要:python里remove函数 举例 a=['s','d','s','c']printa.remove('s')在pycharm中执行结果是None。 原因 这样输出的话是输出的remove函数的返回值,但是这个函数是没有返回值的,所以输出的结果就是none。 要想输出不是None的话,需要这样写:
阅读全文