10 2020 档案
摘要:print(5>3<4) print(5>3<2) 运行结果: True False Python中这个表达式相当于5>3 and 3<4 2. x=1 y=2 max=x if x>y else y print(max)运行结果:2 Python中该方法用起来与Java还是有区别的,Java写法:
阅读全文
摘要:1 #字符串处理 2 str="1234567" 3 print(str[:2]) 4 print(str[-2:]) 5 print(str[:-2]) 运行结果: 12 67 12345 2.字符串拼接 1 newStr="#".join(str) 2 print(newStr) 运行结果: 1
阅读全文
摘要:类属性 class Human(object): taisheng = True 为什么要叫类属性呢,因为这个属性是和类绑定的,并不是和实例绑定的。胎生这个属性是全人类共有的,并不是某个人特殊拥有的属性。 实例属性 class Human(object): def __init__(self, na
阅读全文
摘要:算术运算符 运算符描述 + 相加 - 相减 * 相乘 / 相除 % 取模 ** 幂 // 整除 比较运算符 运算符描述 == 等于 != 不等于 <> 不等于 > 大于 < 小于 >= 大于或等于 <= 小于或等于 赋值运算符 运算符描述 = 赋值 += a += b 等价于 a = a + b -
阅读全文
摘要:1.字符串 msg='hello world1' print(msg) print(msg[0]) print(msg[:3]) print(msg[2:5]) print(msg[:5]) print(msg*2) print(3*msg) print(msg+" GGBond") 运行结果: 1
阅读全文

浙公网安备 33010602011771号