python教程 lambda map filter
def square_1(x): return x**2 sum_list=[1,2,3,4] map(square_1,sum_list) list(map(square_1,sum_list)) def check...
python extend 和append
append每次只添加一个元素,并不会因为这个元素是序列而将其展开: In [28]: a.append([11, 12]) print a [10, 11, 12, 11, [11, 12]] 向列表添加序列...
python 排序函数
l.sort() 会将列表中的元素按照一定的规则排序: In [33]: a = [10, 1, 11, 13, 11, 2] a.sort() print a [1, 2, 10, 11, 11, 13]...
python 将列表按固定数值分隔成多个列表
data_cut=[] def cut_length(data,x): data_cut_use=data[:x] data_re=data[x:] data_cut.append((data_cut_use...
python 'utf-8' codec can't decode byte
将 encoding=’utf-8’ 改为gbk本文参考链接:https://blog.csdn.net/dudu3332/article/details/102855400...
python re.compile函数
正则表达式功能十分强大。 “有些人面临一个问题时会想:‘我知道,可以用正则表达式来解决这个问题。’于是现在他们就有两个问题了”——Jamie Zawinski 同时正则表达式很难掌握。 正则表达式的各种规则就不在此赘述了,以下介绍在p...
python zip函数
seq1, seq2 分别代表了序列类型的数据。通过实验来理解上面的文档: >>> a = "qiwsir" >>> b = "github" >>> zip(a,b) [('q...
python enumerate 函数
enumerate 这是一个有意思的内置函数,本来我们可以通过 for i in range(len(list))的方式得到一个 list 的每个元素索引,然后在用 list[i]的方式得到该元素。如果要同时得到元素索引和元素怎...
python 去除字符串中间的空格
>>> a = 'hello world' >>> a.replace(' ', '') 'helloworld'本文参考链接:https://blog.csdn.net/dudu3332/artic...
python 函数习题二
问题 Functions and Methods Homework Complete the following questions: Write a function that computes the volume of a...