-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.3 运算符 #22
Comments
算术运算符以下假设变量: a=10,b=20:
|
比较(关系)运算符以下假设变量a为10,变量b为20:
|
赋值运算符以下假设变量a为10,变量b为20:
|
位运算符下表中假设变量 a 为 60,b 为 13:
|
逻辑运算符以下假设变量 a 为 10, b为 20:
|
成员运算符成员运算符用于判断集合类(包括字符串、列表或元组)变量中是否包含或者不包含某个元素。 a = 10
b = 20
list = [1, 2, 3, 4, 5 ];
if ( a in list ):
print "1 - 变量 a 在给定的列表中 list 中"
else:
print "1 - 变量 a 不在给定的列表中 list 中"
if ( b not in list ):
print "2 - 变量 b 不在给定的列表中 list 中"
else:
print "2 - 变量 b 在给定的列表中 list 中" |
身份运算符身份运算符用于判断两个变量的引用是否相同,类似于 C 语言中地址比较。
>>> 1000 is 10**3
False
>>> 1000 == 10**3
True >>> "a" is "a"
True
>>> "aa" is "a" * 2
True
>>> x = "a"
>>> "aa" is x * 2
False
>>> "aa" is intern(x*2)
True 参考 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
参考
The text was updated successfully, but these errors were encountered: