Python常见函数总结
来源:互联网 发布:nginx 视频点播服务器 编辑:程序博客网 时间:2024/05/18 06:31
- List.extend:
extend() 函数用于在列表末尾一次性追加另一个序列中的多个值(用新列表扩展原来的列表)。
aList = [123, 'xyz', 'zara', 'abc', 123];bList = [2009, 'manni'];aList.extend(bList)print "Extended List : ", aList ;
输出
Extended List : [123, 'xyz', 'zara', 'abc', 123, 2009, 'manni']
2.collections.Counter()
Counter是一个简单的计数器,例如,统计字符出现的个数:
>>> from collections import Counter>>> c = Counter()>>> for ch in 'programming':... c[ch] = c[ch] + 1...>>> cCounter({'g': 2, 'm': 2, 'r': 2, 'a': 1, 'i': 1, 'o': 1, 'n': 1, 'p': 1})
3.collections.Counter().most_common([:n-1])
取出计数最多的n个数
4.zip(dictionary.values(), dictionary.keys())
保存为二元组
5.raise NotImplementedError(“Each Model must re-implement this method.”)
未实现接口会弹出错误
6.Python class中的_ cal l_()方法
class Hello_world(object): def __call__(self, string): print "Hello ", string if __name__ = main: h = Hello_world() h("world")>> Hello world
7.判断两个列表是否相等numpy.allclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False)
如果两个列表各元素的差值都在一定的容忍度内相等,则返回True()
if the following equation is element-wise True, then allclose returns True.
absolute(a - b) <= (atol + rtol * absolute(b))
阅读全文
0 0
- Python常见函数总结
- python常见函数修饰符总结
- python常见函数修饰符总结(不断更新)
- python入门笔记--常见函数总结(重要)
- python常见错误总结
- python常见函数
- Python常见函数
- Python常见函数讲解
- Python常见文件函数
- python常见函数
- Python List常见函数
- STL常见函数总结
- mysql 常见函数总结
- python常见错误总结结
- python中常见函数使用
- python中matplotlib常见函数
- c语言常见函数总结
- 常见js 函数集合总结
- R-FCN/Faster-rcnn使用snapshot继续训练
- 使用JDK自带的keytool工具生成证书
- Android Studio导入新的项目卡住长期不动解决办法
- STC89C52MCU--内外部资源1
- input踩坑大集合,持续更新~
- Python常见函数总结
- MPC 环境搭建
- uboot How-to
- android.os.TransactionTooLargeException异常
- HTML5规范
- Python笔记(6)模块
- 国内 Android 个人与团队博客汇总
- 搜索算法调整背景下优化人员应如何应对
- 静态方法使用@Autowired注解报null问题