原创 rpm學習

https://www.cnblogs.com/SQL888/p/5776442.html https://bintray.com/jfrog/artifactory-pro/jfrog-artifactory-pro-zip/6.3.

原创 保存函數的元數據

裝飾器 from functools import wraps def decorate1(func): "This is decorate1" @wraps(func) def wrapper(*args,

原创 Mongodb

db //show db nameuse demoshow databasesshow collectionsCtrl + L //clear screen> db.goo.save({_id:4, x:1, y:true}) Write

原创 斐波那契數列

題目描述大家都知道斐波那契數列,現在要求輸入一個整數n,請你輸出斐波那契數列的第n項。n<=39# -*- coding:utf-8 -*- class Solution: def Fibonacci(self, n):

原创 python實現基本算法

1. 冒泡排序 本文采用兩種方法進行冒泡排序, 第一種:第一次排序後,數組中的第一個元素最小 def bubble_sort(lists): # 冒泡排序 count = len(lists) for i in

原创 static and class method

the different between static method and class method class A(object): @classmethod def func1(self, *args):

原创 二維數組中的查找

題目描述在一個二維數組中,每一行都按照從左到右遞增的順序排序,每一列都按照從上到下遞增的順序排序。請完成一個函數,輸入這樣的一個二維數組和一個整數,判斷數組中是否含有該整數。# -*- coding:utf-8 -*- class Sol

原创 使用正則表達式re

郵箱可以以數字和字母開頭,但是不能以下劃線開頭,以.com結尾,返回郵箱的個數 import re str1 = '[email protected]@[email protected]' reg_str1 = r'([a-zA

原创 根據另一個數組進行排序

一個數組根據另一個數組進行排序 a = ['1', '5', '4', '3'] b = ['e', 'f', 'q', 'o'] print "before sort" print a print b n = len(a) for i

原创 namedtuple

通過名稱而不是index來訪問元素 from collections import namedtuple In [20]: S = namedtuple('S', ['name', 'id']) In [21]: sub = S('w

原创 生成器(generator)和迭代器(Iterator)

迭代器用於從集合中取出元素;而生成器用於“憑空”生成元素。 在 Python 中,使用了 yield 的函數被稱爲生成器(generator)。 練習:輸出1到10乘以2的值. def gen10(): for i in ran

原创 compress

篩選序列中的大於0元素 In [1]: from itertools import compress In [2]: a = ['s', 'v', 'x'] In [3]: b = [1, 0, 7] In [4]: more0

原创 使用lambda進行排序

1.使用lambda對list進行排序 >>> a = [('a',1),('b',5),('e',4),('f',2)] >>> sorted(a,key=lambda a :a[1]) [('a', 1), ('f', 2), ('

原创 裝飾器實現單例模式

what is singleton pattern?the singleton pattern is a software design pattern that restricts the instantiation of a clas

原创 goroutine

package main import ( "fmt" "time" "sync" ) func main() { var waitGrp sync.WaitGroup waitGrp.Add(