博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
读python官方教程的一些记录
阅读量:7184 次
发布时间:2019-06-29

本文共 1866 字,大约阅读时间需要 6 分钟。

hot3.png

1、list 和 tuple的区别?

Though tuples may seem similar to lists, they are often used in different situations and for different purposes. Tuples are immutable, and usually contain an heterogeneous sequence of elements that are accessed via unpacking (see later in this section) or indexing (or even by attribute in the case of namedtuples). Lists are mutable, and their elements are usually homogeneous and are accessed by iterating over the list.

2、关于比较关键字和优先级 The conditions used in while and if statements can contain any operators, not just comparisons.

The comparison operators in and not in check whether a value occurs (does not occur) in a sequence. The operators is and is not compare whether two objects are really the same object; this only matters for mutable objects like lists. All comparison operators have the same priority, which is lower than that of all numerical operators.

Comparisons can be chained. For example, a < b == c tests whether a is less than b and moreover b equals c.

Comparisons may be combined using the Boolean operators and and or, and the outcome of a comparison (or of any other Boolean expression) may be negated with not. These have lower priorities than comparison operators; between them, not has the highest priority and or the lowest, so that A and not B or C is equivalent to (A and (not B)) or C. As always, parentheses can be used to express the desired composition.

The Boolean operators and and or are so-called short-circuit operators: their arguments are evaluated from left to right, and evaluation stops as soon as the outcome is determined. For example, if A and C are true but B is false, A and B and C does not evaluate the expression C. When used as a general value and not as a Boolean, the return value of a short-circuit operator is the last evaluated argument.

转载于:https://my.oschina.net/u/2525142/blog/626563

你可能感兴趣的文章
我在tmux中最不可少的配置: 用鼠标切换窗口/调节分屏大小
查看>>
tamper绕WAF详解
查看>>
Static Classes and Static Class Members
查看>>
Linux 索引节点(inode)详解
查看>>
[saiku] 简化/汉化/设置默认页
查看>>
使用nginx搭建https服务器(转)
查看>>
Hibernate注解
查看>>
[转]World Wind Java开发之四——搭建本地WMS服务器
查看>>
3D数学基础:四元数与欧拉角之间的转换
查看>>
算法导论:二叉搜索树
查看>>
【译】Spring 4 自动装配、自动检测、组件扫描示例
查看>>
使用VS Code从零开始开发调试.NET Core 1.1
查看>>
openssl req 证书请求及自签名证书
查看>>
《linux 内核全然剖析》编译linux 0.12 内核 Ubuntu 64bits 环境
查看>>
路由器不重启,是否ip就永远不变
查看>>
安卓数据传递之---putextra与putextras
查看>>
【后会有期】
查看>>
Codeforces Round #346 (Div. 2) - D Bicycle Race
查看>>
nginx php上传大小设置
查看>>
spring原理机制
查看>>