github上为项目添加协同开发者;python Built-in Functions

xiaoxiao2021-02-28  13

github上为项目添加协同开发者

1. 进入项目有页然后点击setting

2.点击左侧collaborators

3.输入email或者github账户名来搜索要加入项目的协同开发者

4.系统将会自动向添加的开发者发送确认邮件,或者你也可以拷贝邀请链接发送给协同开发者 等协同开发者打开邀请链接确认后就可以参与到项目开发中来了

python Built-in Functions

abs(x)#求绝对值;参数必须是数字,否则报异常错误 all(iterable)#当所有迭代元素为真返回true;或者迭代参数为空({}) any(iterable)#与上相反 bin(x)#将数字装换为二进制字符串 bool([x])#根据真值判断程序返回True or False chr(i)#返回字符串,如果参数的ASCII码值是整数 ord(i)#与上面相反 cmp(x, y)#比对两个对象返回整数值作为结果. The return value is negative if x < y, zero if x == y and strictly positive if x > y. divmod(a,b)#返回两个数相除之后的结果与余数,返回值为元祖 eg:

>>> divmod(9,5) (1, 4)

enumerate(sequence, start=0)#Return an enumerate object. sequence must be a sequence, an iterator, or some other object which supports iteration. eg:

>>> seasons = ['Spring', 'Summer', 'Fall', 'Winter'] >>> list(enumerate(seasons)) [(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')]

filter(function, iterable)#对sequence中的item依次执行function(item),将执行结果为True的item组成一个List/String/Tuple(取决于sequence的类型)返回

map(function, sequence) :对sequence中的item依次执行function(item),见执行结果组成一个List返回

reduce(function, sequence, starting_value):对sequence中的item顺序迭代调用function,如果有starting_value,还可以作为初始值调用,例如可以用来对List求和:

>>> def add(x,y): return x + y >>> reduce(add, range(1, 11)) 55

hex(x) Convert an integer number (of any size) to a lowercase hexadecimal string prefixed with “0x”, for example:

>>> hex(255) '0xff'

lambda:这是Python支持一种有趣的语法,它允许你快速定义单行的最小函数,类似与C语言中的宏,这些叫做lambda的函数,是从LISP借用来的,可以用在任何需要函数的地方:

>>> g = lambda x: x * 2 >>> g(3) 6

isinstance(object, classinfo) Return true if the object argument is an instance of the classinfo argument, or of a (direct, indirect or virtual) subclass thereof.

max(iterable[, key]) max(arg1, arg2, *args[, key]) Return the largest item in an iterable or the largest of two or more arguments.

min(iterable[, key]) min(arg1, arg2, *args[, key]) Return the smallest item in an iterable or the smallest of two or more arguments.

pow(x, y[, z])¶ Return x to the power y; if z is present, return x to the power y, modulo z (computed more efficiently than pow(x, y) % z).

range(stop) range(start, stop[, step]) This is a versatile function to create lists containing arithmetic progressions.

>>> range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> range(1, 11) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>> range(0, 30, 5) [0, 5, 10, 15, 20, 25] >>> range(0, 10, 3) [0, 3, 6, 9] >>> range(0, -10, -1) [0, -1, -2, -3, -4, -5, -6, -7, -8, -9] >>> range(0) [] >>> range(1, 0) []

round(number[, ndigits]) Return the floating point value number rounded to ndigits digits after the decimal point. If ndigits is omitted, it defaults to zero.

set([iterable]) Return a new set object, optionally with elements taken from iterable

>>> set([1,2,3,4]) set([1, 2, 3, 4])

class slice(stop) class slice(start, stop[, step]) Return a slice object representing the set of indices specified by range(start, stop, step).

sorted(iterable[, cmp[, key[, reverse]]]) Return a new sorted list from the items in iterable.

>>> sorted([1,4,8,4,34,6,7]) [1, 4, 4, 6, 7, 8, 34]

class str(object=”)¶ Return a string containing a nicely printable representation of an object. For strings, this returns the string itself.

sum(iterable[, start]) Sums start and the items of an iterable from left to right and returns the total. start defaults to 0.

tuple([iterable]) Return a tuple whose items are the same and in the same order as iterable’s items.

class type(object) class type(name, bases, dict) With one argument, return the type of an object. The return value is a type object.

xrange(stop) xrange(start, stop[, step]) This function is very similar to range(), but returns an xrange object instead of a list.

zip([iterable, …]) This function returns a list of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables.

>>> x = [1, 2, 3] >>> y = [4, 5, 6] >>> zipped = zip(x, y) >>> zipped [(1, 4), (2, 5), (3, 6)] >>> x2, y2 = zip(*zipped) >>> x == list(x2) and y == list(y2) True
转载请注明原文地址: https://www.6miu.com/read-1250214.html

最新回复(0)