龙空技术网

学习知多少(python篇):表达式与内置对象

LearningYard学苑 234

前言:

此刻兄弟们对“python程序设计基础董付国答案”都比较关心,兄弟们都需要学习一些“python程序设计基础董付国答案”的相关文章。那么小编同时在网摘上搜集了一些有关“python程序设计基础董付国答案””的相关文章,希望看官们能喜欢,姐妹们快快来学习一下吧!

分享兴趣,传播快乐,增长见闻,留下美好!

亲爱的您,这里是LearningYard学苑。今天小编为大家带来“学习知多少(python篇):表达式与内置对象”,欢迎您的访问。

Share interests, spread happiness, increase knowledge, and leave a good legacy!

Dear you, this is The LearningYard Academy. Today Xiaobian brings you "Learn how much to know (python):Expressions and built-in objects”, welcome your visit.

一、关键字

One. Keywords

Python关键字是特殊的保留字,它为编译器/解释器传达了特殊的含义。每个关键字都有特殊含义和特定操作。python关键字只允许用来表达特定的语义,不允许通过任何方式改变他们的含义,也不能作为变量名、函数名或者类名等标识符。

Python keywords are special reserved words that convey a special meaning to the compiler/interpreter. Each keyword has a special meaning and a specific action. Python keywords are only allowed to express specific semantics, and they are not allowed to change their meaning in any way, nor can they be used as identifiers such as variable names, function names, or class names.

1、内置常量

False None True

2、逻辑与运算符

and not or

3、判断与循环

if elif else

for while

break continue

4、函数

def lambda

pass return yied

5、异常处理

try except finally raise assert

6、导入模块包

import from

7、重命名

as

8、变量

global nonlocal

9、类

class

10、删除

del

11、上下文管理

with

1、Built-in constants

False None True

2. Logic and operators

and not or

3. Judgment and circulation

if elif else

for while

break continue

4. Functions

def lambda

pass return yied

5. Exception handling

try except finally raise assert

6. Import the module package

import from

7. Rename

as

8. Variables

global nonlocal

9. Class

class

10. Deletion

del

11. Context management

with

二、内置函数

Two、 Built-in functions

内置函数是python内置对象类型之一,不需要额外导入任何模块即可直接使用,这些内置对象都封装在内置板块__builtins__之中。

Built-in functions are one of Python's built-in object types, which can be used directly without importing any additional modules, and these built-in objects are encapsulated in the built-in plate __builtins__.

1、abs(x)

返回数字x的绝对值或复数的模。

2、ascii(obj)

把对象转换成ASCII码表现形式,必要的时候使用转义字符来表示特定的字符。

3、bin(x)

把整数x转换成二进制串表示形式。

4、chr(x)

返回Unicode编码为x的字符。

5、filter(func,seq)

返回filter对象,其中包含序列seq中是的单参数函数func返回值为True的那些对象。

6、help(obj)

返回对象obj的帮助信息。

7、len(obj)

返回对象obj包含的元素个数,适用于元组、列表、集合、字典、字符串以及range对象,不适用于具有惰性求值特点的生成器对象和map、zip等迭代对象。

8、list([x])、set([x])、tupli([x])、dict([x])

把对象x转换为列表、集合、元组或字典并返回,或生成空列表、空集合、空元组、空字典。

9、map(func,*iterables)

返回包含若干函数值的map对象,函数func的参数分别来自于iterables指定的一个或多个迭代对象。

10、range([start,]end[,step])

返回range对象,其中包含左闭右开区间[start,end]内以step为步长的整数。

1、abs(x)

Returns the absolute value of the number x or the modulus of a complex number.

2、ascii(obj)

Convert objects into ASCII representations, using escape characters to represent specific characters when necessary.

3、bin(x)

Converts the integer x to binary string representation.

4、chr(x)

Returns characters encoded in Unicode as x.

5、filter(func,seq)

Returns a filter object that contains those objects that are returned to true by the single-parameter function func in the sequence seq.

6、help(obj)

Returns help information for the object obj.

7、len(obj)

Returns the number of elements contained in the obj object, which is suitable for tuples, lists, collections, dictionaries, strings, and range objects, and is not applicable to generator objects and iteration objects such as map and zip with lazy evaluation characteristics.

8、list([x])、set([x])、tupli([x])、dict([x])

Converts the object x to a list, collection, tuple, or dictionary and returns, or generates an empty list, empty collection, empty tuple, empty dictionary.

9、map(func,*iterables)

Returns a map object containing several function values, the arguments of the func function from one or more iteration objects specified by iterables.

10、range([start,]end[,step])

Returns a range object containing integers with step in the left and right open interval [start, end].

三、案例

Three. Cases

今天的分享就到这里了。

如果您对今天的文章有独特的想法,

欢迎给我们留言,

让我们相约明天。

祝您今天过得开心快乐!

That's all for today's sharing.

If you have a unique idea for today’s article,

please leave us a message,

and let us meet tomorrow.

I wish you a happy day !

本文由learningyard新学苑原创,如有侵权,请联系我们!

翻译来源于谷歌翻译

部分来源于

百度文库

清华大学出版 董付国《Python程序设计基础》

编辑&排版|百味

审核|闫庆红

标签: #python程序设计基础董付国答案