用户:
宇宙之初查看:1 回复:5 评论:1 创建时间:2018-11-15T15:47:47
Python中的7个运算符:(ret是返回值的意思)
not
ret = not 条件,not的结果和"条件"的值相反
or,
ret = left or right,只要有一个值为True,or的结果就是True
and
ret = left and right,只要有一个值为False,and的结果就是False
not or
ret = not(left or right), 只有left和right有一个为True时,not or的结果就是False
not and
ret = not(left and right),只有left和right有一个为False时,not and的结果就是True
!=
ret = left != right,left和right的值不相等,!=的结果就是True
==
ret = left == right,left和right的值相等,==的结果就是True
优先级关系:or<and<not
同一优先级默认从左往右计算
上题目:
(True and not (False and (True and False)))or ('True' == 'False') and ((not (not (123+456 == '579') or not (True == False) and (True and False)) or ('Python' != 'Pythen')) or not(True and True)) and (('tttttt' == 'ttttt') or (True or (not False)))
PS:不准作弊,如果实在不会,先留言“不会”把上面代码复制到Python的IDLE中,回车。