免费seo网站诊断免费,免费如何创建网站平台,建立链接,课程网站怎么做1、Python对象 Python使用对象模型来存储数据#xff0c;构造任何类型的值都是一个对象。所有的对象都有三个特性#xff1a; 身份#xff0c;可通过内建函数id()查看#xff0c;这个值即该对象的内存地址。类型#xff0c;可通过内建函数type()查看。值#xff0c;对象表… 1、Python对象 Python使用对象模型来存储数据构造任何类型的值都是一个对象。所有的对象都有三个特性 身份可通过内建函数id()查看这个值即该对象的内存地址。类型可通过内建函数type()查看。值对象表示的数据项。code classhljs python has-numbering styledisplay: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: Source Code Pro, monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background: transparent;span classhljs-prompt stylecolor: rgb(0, 102, 102); box-sizing: border-box; /spanp span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;12/span
span classhljs-prompt stylecolor: rgb(0, 102, 102); box-sizing: border-box; /spanid(p)
span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;31108092/span
span classhljs-prompt stylecolor: rgb(0, 102, 102); box-sizing: border-box; /spantype(p)
type span classhljs-string stylecolor: rgb(0, 136, 0); box-sizing: border-box;int/span
span classhljs-prompt stylecolor: rgb(0, 102, 102); box-sizing: border-box; /spanp
span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;12/span
span classhljs-prompt stylecolor: rgb(0, 102, 102); box-sizing: border-box; /span/codeul classpre-numbering stylebox-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);li stylebox-sizing: border-box; padding: 0px 5px;1/lili stylebox-sizing: border-box; padding: 0px 5px;2/lili stylebox-sizing: border-box; padding: 0px 5px;3/lili stylebox-sizing: border-box; padding: 0px 5px;4/lili stylebox-sizing: border-box; padding: 0px 5px;5/lili stylebox-sizing: border-box; padding: 0px 5px;6/lili stylebox-sizing: border-box; padding: 0px 5px;7/lili stylebox-sizing: border-box; padding: 0px 5px;8/li/ul 2、标准类型 整型Integer长整型Long integer浮点型float复数型complex number布尔型bool字符串string列表list元组tuple字典dictionary。 3、其他内建类型 type类型对象 type类型本身就是一个对象它的类型为‘type’。 code classhljs haskell has-numbering styledisplay: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: Source Code Pro, monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background: transparent; span classhljs-typedef stylebox-sizing: border-box;span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;type/spanspan classhljs-container stylebox-sizing: border-box;(1)/span/span
span classhljs-typedef stylebox-sizing: border-box;span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;type/span int/spanspan classhljs-typedef stylebox-sizing: border-box;span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;type/spanspan classhljs-container stylebox-sizing: border-box;(span classhljs-title stylebox-sizing: border-box;type/span(1)/span)/span
span classhljs-typedef stylebox-sizing: border-box;span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;type/span span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;type/span/span/codeul classpre-numbering stylebox-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);li stylebox-sizing: border-box; padding: 0px 5px;1/lili stylebox-sizing: border-box; padding: 0px 5px;2/lili stylebox-sizing: border-box; padding: 0px 5px;3/lili stylebox-sizing: border-box; padding: 0px 5px;4/li/ul None——Python的Null对象 Python有一个特殊的类型称作Null对象或者NoneType它只有一个值NoneNone的布尔值为False。 文件 集合函数/方法模块类 4、内部类型 内部类型我们一般不会过多关注与使用了解一下即可。 代码对象 代码对象是编译过的Python源代码片段可执行。可以通过内建函数compile()得到代码对象。代码对象可以被exec命令或者内建函数eval()执行。 帧 跟踪记录对象 程序出现异常退出时一个包含针对异常的栈跟踪信息的跟踪记录对象被创建 code classhljs ruby has-numbering styledisplay: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: Source Code Pro, monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background: transparent; prispan classhljs-constant stylebox-sizing: border-box;Traceback/span (most recent call last)span classhljs-symbol stylecolor: rgb(0, 102, 102); box-sizing: border-box;:/spanspan classhljs-constant stylebox-sizing: border-box;File/span span classhljs-string stylecolor: rgb(0, 136, 0); box-sizing: border-box;stdin/span, line span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;1/span, span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;in/span span classhljs-class stylebox-sizing: border-box;span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;module/span/spanspan classhljs-constant stylebox-sizing: border-box;NameError/spanspan classhljs-symbol stylecolor: rgb(0, 102, 102); box-sizing: border-box;:/span name span classhljs-string stylecolor: rgb(0, 136, 0); box-sizing: border-box;pri/span is span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;not/span span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;defined/span/codeul classpre-numbering stylebox-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);li stylebox-sizing: border-box; padding: 0px 5px;1/lili stylebox-sizing: border-box; padding: 0px 5px;2/lili stylebox-sizing: border-box; padding: 0px 5px;3/lili stylebox-sizing: border-box; padding: 0px 5px;4/li/ul 切片对象 当使用Python的切片语法时就会创建切片对象。 省略对象 用于切片语法中起记号作用。 如 str[::2]之类。 Xrange对象 调用内建函数xrange()会生成一个XRange对象xrange是range的兄弟版本用于需要节省内存 或 range无法完成的超大数据集场合。 5、标准类型操作符 对象值的比较 对象身份比较 这个涉及到Python“引用计数”的相关知识上一篇文章中有总结。Python还提供了is和is not操作符来测试两个变量是否指向同一个对象。 code classhljs python has-numbering styledisplay: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: Source Code Pro, monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background: transparent;span classhljs-prompt stylecolor: rgb(0, 102, 102); box-sizing: border-box; /spana span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;1/span
span classhljs-prompt stylecolor: rgb(0, 102, 102); box-sizing: border-box; /spanb a
span classhljs-prompt stylecolor: rgb(0, 102, 102); box-sizing: border-box; /spanc span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;2/span
span classhljs-prompt stylecolor: rgb(0, 102, 102); box-sizing: border-box; /spana b
span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;True/span
span classhljs-prompt stylecolor: rgb(0, 102, 102); box-sizing: border-box; /spana span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;is/span c
span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;False/span
span classhljs-prompt stylecolor: rgb(0, 102, 102); box-sizing: border-box; /spana span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;is/span span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;not/span c
span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;True/span
span classhljs-prompt stylecolor: rgb(0, 102, 102); box-sizing: border-box; /spana span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;is/span b
span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;True/span/codeul classpre-numbering stylebox-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);li stylebox-sizing: border-box; padding: 0px 5px;1/lili stylebox-sizing: border-box; padding: 0px 5px;2/lili stylebox-sizing: border-box; padding: 0px 5px;3/lili stylebox-sizing: border-box; padding: 0px 5px;4/lili stylebox-sizing: border-box; padding: 0px 5px;5/lili stylebox-sizing: border-box; padding: 0px 5px;6/lili stylebox-sizing: border-box; padding: 0px 5px;7/lili stylebox-sizing: border-box; padding: 0px 5px;8/lili stylebox-sizing: border-box; padding: 0px 5px;9/lili stylebox-sizing: border-box; padding: 0px 5px;10/lili stylebox-sizing: border-box; padding: 0px 5px;11/li/ul 我们通过id也可以直接判断它们是否指向同一对象 code classhljs objectivec has-numbering styledisplay: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: Source Code Pro, monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background: transparent; span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;id/span(a),span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;id/span(b),span classhljs-keyword stylecolor: rgb(0, 0, 136); box-sizing: border-box;id/span(c)
(span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;31108224/span, span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;31108224/span, span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;31108212/span)/codeul classpre-numbering stylebox-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);li stylebox-sizing: border-box; padding: 0px 5px;1/lili stylebox-sizing: border-box; padding: 0px 5px;2/li/ul 6、标准类型内建函数 cmp(obj1,obj2) obj1大于obj2则返回1小于返回-1等于返回0。 code classhljs python has-numbering styledisplay: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: Source Code Pro, monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background: transparent;span classhljs-prompt stylecolor: rgb(0, 102, 102); box-sizing: border-box; /spana,b,c,d span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;1/span,span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;2/span,span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;3/span,span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;2/span
span classhljs-prompt stylecolor: rgb(0, 102, 102); box-sizing: border-box; /spancmp(b,a),cmp(b,c),cmp(b,d)
(span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;1/span, -span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;1/span, span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;0/span)/codeul classpre-numbering stylebox-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);li stylebox-sizing: border-box; padding: 0px 5px;1/lili stylebox-sizing: border-box; padding: 0px 5px;2/lili stylebox-sizing: border-box; padding: 0px 5px;3/li/ul type(obj) str()、repr()、”操作符 str()、repr()、”操作符都能够以字符串的方式获取对象的内容。str()获得的字符串可读性好repr()获取的字符串通常可以用来重新获得该对象。 code classhljs python has-numbering styledisplay: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: Source Code Pro, monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background: transparent;span classhljs-prompt stylecolor: rgb(0, 102, 102); box-sizing: border-box; /spanstr([span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;1/span,span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;2/span,span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;3/span])
span classhljs-string stylecolor: rgb(0, 136, 0); box-sizing: border-box;[1, 2, 3]/span
span classhljs-prompt stylecolor: rgb(0, 102, 102); box-sizing: border-box; /spanrepr([span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;1/span,span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;2/span,span classhljs-number stylecolor: rgb(0, 102, 102); box-sizing: border-box;3/span])
span classhljs-string stylecolor: rgb(0, 136, 0); box-sizing: border-box;[1, 2, 3]/span
span classhljs-prompt stylecolor: rgb(0, 102, 102); box-sizing: border-box; /spanspan classhljs-string stylecolor: rgb(0, 136, 0); box-sizing: border-box;[1,2,3]/span
span classhljs-string stylecolor: rgb(0, 136, 0); box-sizing: border-box;[1,2,3]/span/codeul classpre-numbering stylebox-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);li stylebox-sizing: border-box; padding: 0px 5px;1/lili stylebox-sizing: border-box; padding: 0px 5px;2/lili stylebox-sizing: border-box; padding: 0px 5px;3/lili stylebox-sizing: border-box; padding: 0px 5px;4/lili stylebox-sizing: border-box; padding: 0px 5px;5/lili stylebox-sizing: border-box; padding: 0px 5px;6/li/ul 7、类型工厂函数 Python2.2统一了类和类型。原来所谓的内建类型转换函数像int()、type()、list()等都成了工厂函数也就是说他们看上去像函数实质上是类当调用它们时实际上生成了该类型的一个实例像工厂生成货物一样。 8、标准类型的分类 存储模型更新模型访问模型。 9、Python不支持的类型 char或byte指针 整型 Python中没有像C语言那样的int、short、long。当你使用一个整型数值超出范围时python会自动返回一个长整型给你python的长整型表示的数值范围很大。 float vs double Python的浮点类型float实际上是C的double。浮点型总是不精确的故Python还提供了Decimals模块它有任意精度在处理金钱这类确定的值时Decimals模块很有用。 转载于:https://www.cnblogs.com/csdndreamer/p/5490685.html