楼主: Enthuse
904 1

Python object types [推广有奖]

  • 4关注
  • 39粉丝

大师

8%

还不是VIP/贵宾

-

威望
0
论坛币
74718 个
通用积分
800.5314
学术水平
103 点
热心指数
114 点
信用等级
86 点
经验
299322 点
帖子
12978
精华
0
在线时间
5848 小时
注册时间
2007-4-7
最后登录
2024-1-22

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
Everything is an object in Python, even simple numbers. Python programs can be decomposed into modules,
statements, expressions, and objects, as follows:

1. Programs are composed of modules
2. Modules contain statements
3. Statements contain expressions
4. Expressions create and process objects

Here are built-in object types:
1. Basic Core types: Numbers, Strings, Lists, Dictionaries, Tuples, Files, Sets, Booleans, types, None
2.  Program unit types: Functions, modules, classes
3. Implementation related types: Compiled code, stack tracebacks

all built-in types come in with free operations attached to them.  Pythong is dynamically types -- your operations depend on
what you assignment to the object. It is also strongly typed, you can perform only operations that are valid.

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:object python Types type ect statements programs contain numbers objects

沙发
Enthuse 发表于 2015-5-1 23:11:31 |只看作者 |坛友微信交流群
some notes:
1. strings are immutable. for ex. you have to assign it to a list, change the list, and join back to a string. or use bytearray()
2. tuples are immutable. they are not used as often as lists in practice, but their immutability is the whole point when used.
3. use dir() and help() to find how to use an object/type
4. lists are positionally ordered collections of arbitrarily types objects, not necessarily homogeneuous, and they have no fixed size. they are mutable.
5. core data types support arbitrary nesting -- we can nest them in any combination, and as deeply as you like.
6. list comprehension expression is very powerful way to process sequence structures, example:
d=[c*2 for c in 'world']
related tools are map and filter.
7. Dictionaries are mappings from keys to values. use d={} to init dictionaries.
8. missing keys test: if not 'f' in d.
9. sorting keys in map: for key in sorted(d)
10. File objects are the main interface to external files on computer.
11. Binary Bytes files and Unicode text files.
12. sets are created like X=set('hello') or Y={'a',b','c'}. they are unordered collection of unique and immutable objects. it supports set operations as in set theory.
13. user defined classes

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-8 19:24