随笔分类 -  tricks

Python学习笔记+小技巧
只有注册用户登录后才能阅读该文。
posted @ 2019-12-10 20:39 我们分头打钱! 阅读(3) 评论(0) 推荐(0)
摘要:函数名h,v 代表 行和列 (horizontal,vertical) numpy 中 hstack 表示横向拼接两个行数相同的数组 In [42]: np.hstack((arr3,arr4)) Out[42]: array([[ 0, 0, 0, 3, 1, 2, 3, 4], [ 5, 8, 阅读全文
posted @ 2018-04-12 18:03 我们分头打钱! 阅读(246) 评论(0) 推荐(0)
摘要:返回一个字典,包含所有在本函数调用时存在的变量 阅读全文
posted @ 2018-04-08 21:09 我们分头打钱! 阅读(119) 评论(0) 推荐(0)
摘要:>>> a=23414>>> a += 123>>> a23537## >>> prompt = "If you tell us who you are, we can personalize the messages you see.">>> prompt += "\nWhat is your f 阅读全文
posted @ 2018-04-02 22:53 我们分头打钱! 阅读(426) 评论(0) 推荐(0)
摘要:""" setdefault方法参数输入已有键,返回对应值,找不到已有键,创建新键,值为None """ >>> dict4{'abc': 'abc'}>>> dict4.setdefault('aaa')>>> dict4{'abc': 'abc', 'aaa': None}>>> dict4.s 阅读全文
posted @ 2018-03-17 10:41 我们分头打钱! 阅读(105) 评论(0) 推荐(0)
摘要:利用一个字典关系更新另一个字典 >>> a{1: 'one'}>>> b = {'小白':'dog'}>>> a.update(b)>>> a{1: 'one', '小白': 'dog'} 阅读全文
posted @ 2018-03-11 22:54 我们分头打钱! 阅读(126) 评论(0) 推荐(0)
摘要:pop给出一个键弹出值 popitem弹出一个项 >>> a.pop(2)'two'>>> a{1: 'one', 3: 'three', 4: 'four'}>>> a.popitem()(4, 'four')>>> a{1: 'one', 3: 'three'} popitem随机弹出,字典没有 阅读全文
posted @ 2018-03-11 22:51 我们分头打钱! 阅读(282) 评论(0) 推荐(0)
摘要:前拷贝 与 赋值 >>> a = {1:'one',2:'two',3:'three'}>>> b = a.copy()>>> c = a>>> id(a)2217313747232>>> id(b)2217313747304>>> id(c)2217313747232 赋值贴一个新标签在相同数据上 阅读全文
posted @ 2018-03-11 22:46 我们分头打钱! 阅读(109) 评论(0) 推荐(0)
摘要:>>> dir(list)['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr 阅读全文
posted @ 2018-03-11 22:41 我们分头打钱! 阅读(121) 评论(0) 推荐(0)
摘要:fromkeys(S[,v]) 方法: 创建并返回新的字典 New dict with keys from S and values equal to v(v defaults to None). eg: >>>dict1 = {} >>>dict1.fromkeys((1,2,3)) #创建只有键 阅读全文
posted @ 2018-03-11 22:12 我们分头打钱! 阅读(121) 评论(0) 推荐(0)
摘要:src :source 源 dst :destination 目的 fd :file descriptor 文件描述符,形式上是一个非负整数,在Unix下,描述符是一个小整数,实则是一个索引值 阅读全文
posted @ 2018-03-11 15:57 我们分头打钱! 阅读(113) 评论(0) 推荐(0)