• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python3 内置函数

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本节介绍了 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

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

3、debugger

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

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

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

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



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

上一篇:
Python3 爬虫实战教程发布时间:2022-01-22
下一篇:
Python3 日期和时间发布时间:2022-01-22
热门推荐
    热门话题
    阅读排行榜

    扫描微信二维码

    查看手机版网站

    随时了解更新最新资讯

    139-2527-9053

    在线客服(服务时间 9:00~18:00)

    在线QQ客服
    地址:深圳市南山区西丽大学城创智工业园
    电邮:jeky_zhao#qq.com
    移动电话:139-2527-9053

    Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap