![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python基础知识
胖猪猪~
这个作者很懒,什么都没留下…
展开
-
数据结构
Python数据结构:列表(可变)方法描述list.append(x)向列表中添加数据list.extend(L)向列表中添加列表list.insert(i, x)向列表中插入数据,可指定位置list.remove(x)向列表中删除为x的第一个元素list.pop([i])向列表中删除最后一个数据,i表示元素可选择性删除list.clear()删除列表中的所有元素,相当于del a[:]list.sort()列表排序,升序.原创 2021-03-16 18:08:34 · 62 阅读 · 0 评论 -
Python去除字符串多余数据
str3 = " toke my roots grew,moke my dream glow """"去掉字符串多余空格""""方法0,不建议"project1 = str3.rstrip(" ")print("project1: ", project1)project2 = str3.lstrip(" ")print("project2: ", project2)print("project3:", project1 + project2)"方法1"p原创 2021-03-09 15:46:49 · 355 阅读 · 0 评论 -
字符串反转3种简单方法
python解决字符串反转问题1、使用方法""" 字符串反转 """from functools import reduce"方法一"str = "abcd"str1 = str[::-1]print("方法一输出结果:", str1)"方法二"str2 = "hello"str3 = list(str2)print("转换成列表后输出结果:", str3)str3.reverse()str3 = "".join(str3)print("方法二输出结果:", str3)原创 2021-01-10 14:36:01 · 723 阅读 · 1 评论