随笔分类 -  python

摘要:点击查看代码 str1 = ' hello , welcome to the world ' # 去除字符串左右两边空白 str1.strip() 'hello , welcome to the world' # 去除字符串右边空白 str1.rstrip() ' hello , welcome t 阅读全文
posted @ 2022-07-02 17:57 灵、主 阅读(8) 评论(0) 推荐(0) 编辑
摘要:partition() 根据指定的分隔符 (sep) 将字符串进行分割,从字符串左边开始索引分隔符 sep, 索引到则停止索引,返回的是一个包含三个元素的元组 (tuple),即 (head, sep, tail)。 repartiton()是从后往前开始分割 点击查看代码 s = 'hello, 阅读全文
posted @ 2022-07-02 17:50 灵、主 阅读(54) 评论(0) 推荐(0) 编辑
摘要:字符串分割 split() rsplit() 跟split相比,它是从字符串最后面往前开始分割 splitlines() 按照 (\n, \r, \r\n 等) 分隔,分割成列表 点击查看代码 s = 'hello, welcome to the world' # 按空格分割 s.split() [ 阅读全文
posted @ 2022-07-02 17:38 灵、主 阅读(85) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 # reshape用法 # numpy.arange(n).reshape(a,b)依次生成n个自然数,并且以a行b列的数组形式显示 import numpy as np array = np.arange(16).reshape(2, 8) print(array) # output 阅读全文
posted @ 2022-04-30 15:43 灵、主 阅读(283) 评论(0) 推荐(0) 编辑
摘要:https://www.runoob.com/python/python-func-zip.html 阅读全文
posted @ 2022-04-29 10:49 灵、主 阅读(15) 评论(0) 推荐(0) 编辑
摘要:Python map() 函数 | 菜鸟教程 (runoob.com) 阅读全文
posted @ 2022-04-29 10:41 灵、主 阅读(25) 评论(0) 推荐(0) 编辑
摘要:https://www.runoob.com/python/python-func-reduce.html 阅读全文
posted @ 2022-04-29 10:39 灵、主 阅读(8) 评论(0) 推荐(0) 编辑
摘要:set集合《python中文指南》P66 阅读全文
posted @ 2022-04-22 19:48 灵、主 阅读(9) 评论(0) 推荐(0) 编辑
摘要:dict字典《python中文指南》P62 阅读全文
posted @ 2022-04-22 19:47 灵、主 阅读(10) 评论(0) 推荐(0) 编辑
摘要:tuple元组《python中文指南》P59 阅读全文
posted @ 2022-04-22 19:42 灵、主 阅读(7) 评论(0) 推荐(0) 编辑
摘要:list列表《python中文指南》P54 阅读全文
posted @ 2022-04-22 19:40 灵、主 阅读(9) 评论(0) 推荐(0) 编辑
摘要:在字符串中,使用 {} 进行占位,然后在字符串后跟上 .format() 函数,这个函数的参数就是我们要往字符串中填充的变量。 format 函数会依次填充,比如第一个 {} 会取到第一个参数 name,第二个 {} 会取到第二个参数age 阅读全文
posted @ 2022-04-22 19:20 灵、主 阅读(30) 评论(0) 推荐(0) 编辑
摘要:startswith() 判断字符串是否以某字符串开头 endswith() 判断字符串是否以某字符串结尾 阅读全文
posted @ 2022-04-22 18:50 灵、主 阅读(30) 评论(0) 推荐(0) 编辑
摘要:去掉首尾空格 lstrip() 去除左边空格 rstrip() 去除右边空格 strip() 去除左右两边空格 阅读全文
posted @ 2022-04-22 18:48 灵、主 阅读(39) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2022-04-14 18:32 灵、主 阅读(35) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 # subplot创建单个子图 # subplot(nrows, ncols, sharex, sharey, subplot_kw, **fig_kw) # nrows : subplot的行数 # ncols : subplot的列数 # sharex : 所有subplot应该使 阅读全文
posted @ 2022-04-14 16:54 灵、主 阅读(229) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 # figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True) # num:图像编号或名称,数字为编号,字符串为名称 # figsize:指定figure的宽和高,单位为英 阅读全文
posted @ 2022-04-14 16:24 灵、主 阅读(187) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 # 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 阅读全文
posted @ 2022-04-13 23:28 灵、主 阅读(217) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 # np.zeros() # 返回来一个给定形状和类型的用0填充的数组; # zeros(shape, dtype=float, order=‘C’) # shape:形状 # dtype:数据类型,可选参数,默认numpy.float64 # order:可选参数,C:行优先;F:代 阅读全文
posted @ 2022-04-13 22:58 灵、主 阅读(130) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 # sorted(iterable, cmp=None, key=None, reverse=False) # iterable -- 可迭代对象。 # cmp -- 比较的函数,这个具有两个参数,参数的值都是从可迭代对象中取出,此函数必须遵守的规则为,大于则返回1,小于则返回-1,等 阅读全文
posted @ 2022-04-13 22:30 灵、主 阅读(66) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示