1、执行字符串表示的代码
将字符串编译成python能识别或可执行的代码,也可以将文字读成字符串再编译。
>>> s = "print('Life is short....源代码(source)可以表示``Python`模块、语句或表达式。
文件名(filename)将用于运行时错误消息。..., file "", line 1>
>>> exec(r)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
2、计算字符串表示的表达式
将字符串 str 当成有效的表达式来求值并返回计算结果取出字符串中内容...4、过滤器
在函数中设定过滤条件,迭代元素,保留返回值为True 的元素:
>>> f = filter(lambda x: x>10,[i for i in range(1,50,3)]
>>> print...,为那些函数或项为真的可迭代项。