- 博客(468)
- 资源 (1)
- 收藏
- 关注
原创 Jenkins使用整理
In the Global Security, I didn't have a TCP port for JNLP agents enabled, which automatically disables the line "Launch agent via Java Web Start" Manage Jenkins=> Configure Global Security => ...
2018-12-20 18:22:00
542
原创 mac学习整理
xcode-select --switch /build/toolchain/mac32/xcode-7.3/Xcode.app xcode-select --print-path
2018-10-24 11:27:01
660
原创 rpm学习
https://www.cnblogs.com/SQL888/p/5776442.htmlhttps://bintray.com/jfrog/artifactory-pro/jfrog-artifactory-pro-zip/6.3.0https://mvnrepository.com/artifact/org.postgresql/postgresql/9.4-1204-jdbc42...
2018-09-09 23:54:12
487
原创 保存函数的元数据
装饰器from functools import wrapsdef decorate1(func): "This is decorate1" @wraps(func) def wrapper(*args, **kwargs): "This is wrapper func" print('decorate1') ret...
2018-09-03 09:28:19
374
原创 namedtuple
通过名称而不是index来访问元素from collections import namedtupleIn [20]: S = namedtuple('S', ['name', 'id'])In [21]: sub = S('wuwei', '631')In [22]: subOut[22]: S(name='wuwei', id='631')In [23]: sub.nam...
2018-08-25 15:33:10
768
原创 compress
筛选序列中的大于0元素In [1]: from itertools import compressIn [2]: a = ['s', 'v', 'x']In [3]: b = [1, 0, 7]In [4]: more0 = [n > 0 for n in b]In [5]: more0Out[5]: [True, False, True]In [6]: list...
2018-08-25 15:04:49
469
原创 使用正则表达式re
邮箱可以以数字和字母开头,但是不能以下划线开头,以.com结尾,返回邮箱的个数import restr1 = 'w123@126.comwsx123@126.comw123@126.com'reg_str1 = r'([a-zA-Z0-9]+[\.\w]*@[\w]+\.com)'mod = re.compile(reg_str1)items = re.findall(reg_st...
2018-08-13 18:42:06
321
原创 生成器(generator)和迭代器(Iterator)
迭代器用于从集合中取出元素;而生成器用于“凭空”生成元素。在 Python 中,使用了 yield 的函数被称为生成器(generator)。练习:输出1到10乘以2的值.def gen10(): for i in range(10): yield 2*(i+1)g = gen10()for i in g: print ioutput:2...
2018-08-13 09:40:49
356
原创 根据另一个数组进行排序
一个数组根据另一个数组进行排序a = ['1', '5', '4', '3']b = ['e', 'f', 'q', 'o']print "before sort"print aprint bn = len(a)for i in range(n-1): for j in range(1,n-i): if int(a[j-1]) > int(a[j])...
2018-08-12 21:58:55
3996
原创 使用lambda进行排序
1.使用lambda对list进行排序>>> a = [('a',1),('b',5),('e',4),('f',2)]>>> sorted(a,key=lambda a :a[1])[('a', 1), ('f', 2), ('e', 4), ('b', 5)]方法1.用List的成员函数sort进行排序,在本地进行排序,不返回副本方法2.用b...
2018-08-12 21:44:49
11645
原创 generator
生成器>>> def gen123():... print "yield to 1"... yield 1... print "yield to 2"... yield 2... print "yield to 3"... yield 3... >>> g = gen123()>&
2018-08-11 23:27:52
147
原创 实现调用函数功能
1.使用list实现依次调用函数功能def check_network(): print "This is check_network"def check_config(): print "This is check config"def check_io(): print "This is check io"if __name__ == '__main_...
2018-08-10 17:19:21
601
原创 static and class method
the different between static method and class methodclass A(object): @classmethod def func1(self, *args): print "This is func1 of A" @staticmethod def func2(*args): ...
2018-08-07 16:13:38
168
原创 斐波那契数列
题目描述大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项。n<=39# -*- coding:utf-8 -*-class Solution: def Fibonacci(self, n): # write code here def fib_iter(n,x,y): if n==0 : ...
2018-07-13 09:12:00
222
原创 二维数组中的查找
题目描述在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。# -*- coding:utf-8 -*-class Solution: # array 二维列表 def Find(self, target, array): # write code h...
2018-07-13 09:09:37
149
原创 替换空格
题目描述请实现一个函数,将一个字符串中的每个空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。# -*- coding:utf-8 -*-class Solution: # s 源字符串 @classmethod def replaceSpace(self, s): # write c...
2018-07-13 09:07:42
183
原创 旋转数组的最小数字
题目描述把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 输入一个非减排序的数组的一个旋转,输出旋转数组的最小元素。 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。 NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。class Solution: @classmethod def minNum...
2018-07-13 09:03:26
152
原创 Mongodb
db //show db nameuse demoshow databasesshow collectionsCtrl + L //clear screen> db.goo.save({_id:4, x:1, y:true})WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })> db.goo.find(...
2018-07-09 10:35:37
241
原创 windows cmd
netsh interface ip show addressdir /s /b/sLists every occurrence of the specified file name within the specified directory and all subdirectories./bDisplays a bare list of directories and files, with ...
2018-07-06 09:22:56
155
原创 goroutine
package mainimport ( "fmt" "time" "sync")func main() { var waitGrp sync.WaitGroup waitGrp.Add(2) go func() { defer waitGrp.Done() time.Sleep(5 * time.Seco...
2018-07-04 09:00:58
211
原创 装饰器实现单例模式
使用装饰器实现单例程模式def singleton(cls, *args, **kw): instances = {} def _singleton(): if cls not in instances: instances[cls] = cls(*args, **kw) return instances[cls] r...
2018-06-24 14:15:06
795
原创 打印程序运行时间
用装饰器实现打印程序运行时间import timedef print_run_time(func): def wrapper(*args, **kw): start = time.time() func(*args, **kw) end =time.time() - start print "run time is %s"...
2018-06-24 13:54:48
772
原创 python实现基本算法
1. 冒泡排序本文采用两种方法进行冒泡排序,第一种:第一次排序后,数组中的第一个元素最小def bubble_sort(lists): # 冒泡排序 count = len(lists) for i in range(count): for j in range(i + 1, count): if lists[i] &g...
2018-06-22 21:37:49
269
原创 Golang study
Useful URLhttps://golang.org/https://play.golang.org/https://atom.io/https://github.com/nsf/gocode
2018-06-13 09:11:06
242
原创 subprocess
import subprocess_VERBOSE = Truedef run_cmd(cmd): if _VERBOSE: print cmd process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIP...
2018-06-04 16:08:10
639
原创 contextlib
>>> import contextlib>>> @contextlib.contextmanager... def make_context():... print 'enter'... try:... yield {}... except RuntimeError, err:... pri...
2018-06-04 10:29:00
537
原创 dictionary
>>> a = {"1":"WuWei"}>>> name = a.pop('2', [])>>> name[]>>> name = a.pop('2')Traceback (most recent call last): File "<stdin>&
2018-06-03 19:03:09
207
原创 set and frozenset
>>> x = set("A Python")>>> xset(['A', ' ', 'h', 'o', 'n', 'P', 't', 'y'])Sets are implemented in a way, which doesn't allow mutable objects.>>> name = set((["name1", &
2018-06-03 17:44:08
157
原创 textwrap
dedent it’s the design of textwrap.dedent: On the first line you have to set the ammount of space you want to dedent in the lines below, otherwise it will capture the position of the first text to se...
2018-06-03 09:01:15
221
原创 vim配置
把下面的内容粘贴到~/.vimrc中,可以实现自动缩进,tab自动空4个空格功能set filetype=pythonau BufNewFile,BufRead *.py,*.pyw setf python"set autoindent " same level indentset smartindent " next level indent"set expandtab " tabs are s...
2018-04-03 14:53:33
228
原创 Django学习整理
django-admin startproject mysiteIf you want to change the server’s IP, pass it along with the port. Forexample, to listen on all available public IPs (which is useful if you arerunning Vagrant or want...
2018-01-23 11:31:23
262
转载 anaconda使用整理
# 创建一个名为python34的环境,指定Python版本是3.4(不用管是3.4.x,conda会为我们自动寻找3.4.x中的最新版本)conda create--namepython34python=3.4 # 安装好后,使用activate激活某个环境activatepython34# for Windowssource activate pytho
2018-01-23 10:48:07
532
转载 That darn "libtoolize: AC_CONFIG_MACRO_DIR([m4]) conflicts with ACLOCAL_AMFLAGS=-I m4" error
Is caused by using CRLFs in Makefile.am. "m4" != "m4" and thus the libtoolize script will produce an error.If you're using git, I strongly advise adding a .gitattributes file with the following:
2017-05-02 11:12:57
4685
原创 P4python sync code from perforce
P4WORKSPACE = "wsx"P4PATH = "/home/s/Perforce/"P4PORT = "perforce-xxx:1800"def _sync_packages(view_common_path):""" sync from perforce"""p4 = P4()p4.port = P4PORTp4.user = "nn"try:
2017-04-26 15:16:22
1744
原创 初学java整理
extends与implements的区别:extends是继承父类,只要那个类不是声明为final或者那个类定义为abstract的就能继承,JAVA中不支持多重继承,但是可以用接口来实现,这样就用到了implements,继承只能继承一个类,但implements可以实现多个接口,用逗号分开就行了。
2017-03-15 17:08:00
489
转载 设计模式的六大原则
关于设计模式的六大设计原则的资料网上很多,但是很多地方解释地都太过于笼统化,我也找了很多资料来看,发现优快云上有几篇关于设计模式的六大原则讲述的比较通俗易懂,因此转载过来。 原作者博客链接:http://blog.youkuaiyun.com/LoveLion/article/category/738450/7一.单一职责原则 原文链接:http://blog.youkuaiyun.com/
2017-03-13 21:34:02
9185
2
转载 RESTful API 设计最佳实践
来源:http://www.oschina.net/translate/best-practices-for-a-pragmatic-restful-api 数据模型已经稳定,接下来你可能需要为web(网站)应用创建一个公开的API(应用程序编程接口)。需要认识到这样一个问题:一旦API发布后,就很难对它做很大的改动并且保持像先前一样的正确性。现在,网络上有很多关于API设计的思路。但是
2017-02-25 16:09:58
441
原创 SQL遇到错误整理
The credentials you provided for the SQL Server Agent service are invalid. To continue, provide a valid account and password for the SQL Server Agent service.Use the credential that you use to login
2017-02-19 21:23:22
746
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人