发觉很多python coding不怎么用,很多基本结构有所生疏。近期会持续把常用的数据结构用python搞一搞,会更新:
d = {} res = '' for i in range(11): d[i] = chr(i) for i in range(11): key = list(d.keys())[i] value = d[key] new_char = chr(key+ ord(value)) res += new_char print(res)
回文测试:
def isPalindrome(self, s: str) -> bool: s= [c.lower() for c in s if c.isalnum()] return all (s[i] == s[~i] for i in range(len(s)//2))