|
|
|
@ -0,0 +1,56 @@
|
|
|
|
|
math.pow(x,y)——x的y次幂
|
|
|
|
|
math.exp(x)——e的x次幂
|
|
|
|
|
math.expml(x)——e的x次幂-1
|
|
|
|
|
math.sqrt(x)——x的平方根
|
|
|
|
|
math.log(x[,base])——x的对数值,只输入x时,返回自然对数,即lnx
|
|
|
|
|
math.log1p(x)——1+x的自然对数值
|
|
|
|
|
math.log2(x)——x的2的对数值
|
|
|
|
|
math.log10(x)——x的10的对数值
|
|
|
|
|
isalpha(), isdecimal(), isdigit(), isnumeric(), isalnum()
|
|
|
|
|
S.find(sub[, start[, end]])S.index(sub[, start[, end]])
|
|
|
|
|
str.replace(old,new,num)
|
|
|
|
|
str.split(sep=None)
|
|
|
|
|
str.strip(chars)
|
|
|
|
|
str.join(iter)
|
|
|
|
|
ord()
|
|
|
|
|
chr()
|
|
|
|
|
result = x if x < y else y
|
|
|
|
|
# a2-10 九九乘法表
|
|
|
|
|
for i in range(1,10): #输出9行
|
|
|
|
|
for j in range(1,i+1): #输出i列
|
|
|
|
|
print('{}*{}={}\t'.format(i,j,i*j),end='') #输出一项
|
|
|
|
|
print() #换行
|
|
|
|
|
s.index(x,m,n)
|
|
|
|
|
s.count(x)
|
|
|
|
|
列表是一种可以修改数据项的序列。
|
|
|
|
|
del ls[i: j: k]
|
|
|
|
|
ls += ls1
|
|
|
|
|
ls *= n
|
|
|
|
|
ls.append(x)
|
|
|
|
|
ls.clear()
|
|
|
|
|
ls.extend()
|
|
|
|
|
ls.insert(i, x)
|
|
|
|
|
ls.remove(x)
|
|
|
|
|
ls.reverse()
|
|
|
|
|
ls.index(x[, start[, end]])
|
|
|
|
|
newls = sorted(ls, key, reverse)
|
|
|
|
|
reverse=True 降序 reverse=False 升序(默认)
|
|
|
|
|
temp = sorted(Stu_height, key = lambda x : x[1], reverse=True) print(temp)
|
|
|
|
|
数据项:0个或多个,无序,不重复
|
|
|
|
|
元素不能是可变数据类型:list, set, dict
|
|
|
|
|
集合没有索引和位置的概念,不能切片
|
|
|
|
|
s.add(x)
|
|
|
|
|
s.discard(x)
|
|
|
|
|
s.remove(x)
|
|
|
|
|
s.clear()
|
|
|
|
|
len(s)
|
|
|
|
|
set(x)
|
|
|
|
|
字典
|
|
|
|
|
d.keys()
|
|
|
|
|
d.values()
|
|
|
|
|
d.items()
|
|
|
|
|
d.clear()
|
|
|
|
|
k in d# 键
|
|
|
|
|
d.get(k,<default>)
|
|
|
|
|
|
|
|
|
|
|