Python3 内置函数 【Python学习连续,请关注】
创始人
2024-05-30 15:28:42

本节介绍了 Python3 中的内置函数以及调试的两种方法。

内置函数

abs()

dict()

help()

min()

setattr()

all()

dir()

hex()

next()

slice()

any()

divmod()

id()

object()

sorted()

ascii()

enumerate()

input()

oct()

staticmethod()

bin()

eval()

int()

open()

str()

bool()

exec()

isinstance()

ord()

sum()

bytearray()

filter()

issubclass()

pow()

super()

bytes()

float()

iter()

print()

tuple()

callable()

format()

len()

property()

type()

chr()

frozenset()

list()

range()

vars()

classmethod()

getattr()

locals()

repr()

zip()

compile()

globals()

map()

reversed()

__import__()

complex()

hasattr()

max()

round()

delattr()

hash()

memoryview()

set()

Python 调试方法

1、print

print('here')
# 可以发现某段逻辑是否执行# 打印出变量的内容

2、assert

assertfalse, 'blabla'# 如果条件不成立,则打印出 'blabla' 并抛出AssertionError异常

3、debugger

可以通过 pdb、IDE 等工具进行调试。

调试的具体方法这里不展开。

Python 中有两个内置方法在这里也很有帮助:

  • locals: 执行 locals() 之后, 返回一个字典, 包含(current scope)当前范围下的局部变量。

  • globals: 执行 globals() 之后, 返回一个字典, 包含(current scope)当前范围下的全局变量。

相关内容

热门资讯

卓翼科技跌2.05%,成交额4... 4月15日,卓翼科技(维权)盘中下跌2.05%,截至13:48,报7.17元/股,成交4868.70...
孙姓股民向ST章鼓发起索赔 刘...   受损股民可至Hehson股民维权平台登记该公司维权:http://wq.finance.sina...
欧盟对华柠檬酸发起第三次反倾销... 2026年4月14日,欧盟委员会发布公告,应欧盟企业N.V. Citrique Belge S.A....
中国消博会:全球消费新趋势展示... 巴西247新闻网4月13日文章,原题:中国重视发展体验经济,在海南举办大型消费品博览会 随着第六届中...
我国网络视听用户规模10.99... 转自:新华社  4月15日在成都开幕的第13届中国网络视听大会上,《中国网络视听发展研究报告(202...