摘要:
1 = ['Hello','World',10,'IBM','Apple'] res = [value.lower() if isinstance(value,str) else value for value in 1] res = [value.lower() for value in 1 if 阅读全文
摘要:
import math class Round: def __init__(self,r,xy): self.r = r self.xy = xy def Aera(self): return math.pi * self.r ** 2 def Grith(self): return math.pi 阅读全文
摘要:
# 用遍历互换键值对 d1 = {'a':1,'b':2,'c':3} d2 = {} for key,value in d1.items(): d2[value] = key print(d2) # 用列表生成器 d1 = {'a':1,'b':2,'c':3} d2 = {key:value f 阅读全文