'''字符串的比较''' print('apple'>'app') #True print('apple'>'banana') #False print(ord('a'),ord('b')) #97 98 #字符串比较的是 ordinal value print(ord('杨')) #26472 print(chr(97),chr(98)) #a b #内置函数chr可找到ordinal value对应的字母 print(26472) #杨 '''== 和 is 的区别 == 比较的是value is 比较的是id是否相等 ''' a=b='Python' c='Python' d='Py'+'thon' print(a==b,b==c) #True True print(a is b) #True print(a is c) #True print(id(a),id(b),id(c)) #因为字符串的驻留机制,id相等
E:\PycharmProjects\pythonProject\venv\Scripts\python.exe E:/PycharmProjects/pythonProject/demon1/demo20.py True False 97 98 26472 a b 26472 True True True True 2128103624432 2128103624432 2128103624432 进程已结束,退出代码0