随笔分类 - python
摘要:点击查看代码 str1 = ' hello , welcome to the world ' # 去除字符串左右两边空白 str1.strip() 'hello , welcome to the world' # 去除字符串右边空白 str1.rstrip() ' hello , welcome t
阅读全文
摘要:partition() 根据指定的分隔符 (sep) 将字符串进行分割,从字符串左边开始索引分隔符 sep, 索引到则停止索引,返回的是一个包含三个元素的元组 (tuple),即 (head, sep, tail)。 repartiton()是从后往前开始分割 点击查看代码 s = 'hello,
阅读全文
摘要:字符串分割 split() rsplit() 跟split相比,它是从字符串最后面往前开始分割 splitlines() 按照 (\n, \r, \r\n 等) 分隔,分割成列表 点击查看代码 s = 'hello, welcome to the world' # 按空格分割 s.split() [
阅读全文
摘要:点击查看代码 # reshape用法 # numpy.arange(n).reshape(a,b)依次生成n个自然数,并且以a行b列的数组形式显示 import numpy as np array = np.arange(16).reshape(2, 8) print(array) # output
阅读全文
摘要:https://www.runoob.com/python/python-func-zip.html
阅读全文
摘要:Python map() 函数 | 菜鸟教程 (runoob.com)
阅读全文
摘要:https://www.runoob.com/python/python-func-reduce.html
阅读全文
摘要:set集合《python中文指南》P66
阅读全文
摘要:dict字典《python中文指南》P62
阅读全文
摘要:tuple元组《python中文指南》P59
阅读全文
摘要:list列表《python中文指南》P54
阅读全文
摘要:在字符串中,使用 {} 进行占位,然后在字符串后跟上 .format() 函数,这个函数的参数就是我们要往字符串中填充的变量。 format 函数会依次填充,比如第一个 {} 会取到第一个参数 name,第二个 {} 会取到第二个参数age
阅读全文
摘要:startswith() 判断字符串是否以某字符串开头 endswith() 判断字符串是否以某字符串结尾
阅读全文
摘要:去掉首尾空格 lstrip() 去除左边空格 rstrip() 去除右边空格 strip() 去除左右两边空格
阅读全文
摘要:https://blog.csdn.net/AnneQiQi/article/details/64125186?ops_request_misc=&request_id=&biz_id=102&utm_term=python%20scatter()%E5%87%BD%E6%95%B0&utm_med
阅读全文
摘要:点击查看代码 # subplot创建单个子图 # subplot(nrows, ncols, sharex, sharey, subplot_kw, **fig_kw) # nrows : subplot的行数 # ncols : subplot的列数 # sharex : 所有subplot应该使
阅读全文
摘要:点击查看代码 # figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True) # num:图像编号或名称,数字为编号,字符串为名称 # figsize:指定figure的宽和高,单位为英
阅读全文
摘要:点击查看代码 # s.strip(ch) 将字符串头和尾的指定字符ch去掉,如果这里去掉一个之后还是有ch,则继续去掉,直到没有;ch不填,则默认ch=空格 s1 = " a a ab a a ab" s2 = "a a ab" s3 = "aa ab" s4 = "a b ba" print(s1
阅读全文
摘要:点击查看代码 # np.zeros() # 返回来一个给定形状和类型的用0填充的数组; # zeros(shape, dtype=float, order=‘C’) # shape:形状 # dtype:数据类型,可选参数,默认numpy.float64 # order:可选参数,C:行优先;F:代
阅读全文
摘要:点击查看代码 # sorted(iterable, cmp=None, key=None, reverse=False) # iterable -- 可迭代对象。 # cmp -- 比较的函数,这个具有两个参数,参数的值都是从可迭代对象中取出,此函数必须遵守的规则为,大于则返回1,小于则返回-1,等
阅读全文