python is 输出
来源:互联网 发布:java多线程编程项目 编辑:程序博客网 时间:2024/05/28 04:53
a='Hi'
b='Hi'
str1='Ta shi yi ge chi huo'
str2='Ta shi yi ge chi huo'
print(a is b) #true
print(a==b) #true
print(str1 is str2) #false
print(str1==str2) #true
a=256
b=256
print(a is b) #true
print(a==b) #true
a=257
b=257
print(a is b) #false
print(a==b) #true
is 是判断id是否相等即id(a)==id(b) 但为什么只是数值不同 字符串不同 就会让is结果不一样?
这与python缓冲池有关,就int 而言,如果它在区间[-5,256]之间
a=-5
b=-5
不会为b开辟新的空间,只是b指向a的引用
对于字符串也会有对应的判断条件,当一个字符串所有字符都在一个预设字符串中时,就也不开辟新空间 只是引用
这与java中的==很像
阅读全文
0 0
- python is 输出
- python中input输出“Name 'XXX' is not defined问题
- 经典算法问题:“this is a test” 逆序输出为“test a is this”.使用Python实现
- 关于Python输出方式(the value of x + y is z)
- [python] python彩色输出
- python中的is ,is not
- python---打印输出/中文输出
- 尝试将Python程序用管道命令输出到cd时报错 - sys.excepthook is missing lost sys.stderr
- Python Is Not Java
- Python Is Not Java
- What Is Python?
- python is not None
- This is python
- Python的is
- Python中的is
- python == is
- 【Python】 Python输入和输出
- 用python输出中文
- http的post和get区别
- 内联函数--讲的真好
- 如何使用万能地图下载器下载80坐标的等高线
- android.os.DeadObjectException问题解决
- 关于Web Workers你需要了解的七件事
- python is 输出
- CSS动画的初步使用(好像比jQuery流畅)
- Entity Framework Code First 实例
- Codeforces Beta Round #83 (Div. 1 Only) E.Darts 凸多边形面积交
- oracle 用户锁死解锁
- 2017年下半年集中GIS底层
- 实在是搞不下去了,来这里诉诉苦吧
- 循环赛日程表(分治)
- loop语句中输出每次长度不一样的循环结果