File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 21
21
str.split(' ', 1); # 以空格为分隔符,分隔成两个
22
22
```
23
23
* 添加:
24
- * ` append ` 在列表尾部添加,
24
+ * ` append() ` 在列表尾部添加,
25
25
* ` insert(index, obj) ` 可以指定添加顺序
26
26
* 删除:
27
27
* ` list.remove(obj) ` 移除列表中某个值的第一个匹配项
40
40
print(my_list[:3]) # 输出: [10, 20, 30]
41
41
print(my_list[2:]) # 输出: [30, 40, 50]
42
42
```
43
- * 指数相乘用2个乘号 **
43
+ * 指数相乘用2个乘号 `**`
44
44
* 在Python中,有多种方式可以格式化输出。以下是其中几种常用的方式:
45
-
46
45
1. 通过占位符格式化输出:可以使用占位符(例如`%`)将要输出的值插入到字符串中的适当位置。常见的占位符有 `%s`(字符串)、`%d`(整数)、`%f`(浮点数)等。例如:
47
46
48
47
```python
70
69
* x与y ` x and y ` ,x或y ` x or y ` ,非x ` not int(x) `
71
70
* ` x&y ` 位与、` x|y ` 位或,输出按照十进制的形式。
72
71
* ` name in lst ` 检测name是否在lst中
73
- * map 映射功能
72
+ * map(function, iterable,) 函数会根据提供的函数对指定序列做映射。第一个参数 function 以参数序列中的每一个元素调用 function 函数,返回包含每次 function 函数返回值的新列表。
74
73
* 判断一个列表是空
75
74
```
76
75
if len(my_list) == 0
101
100
>>> zip(*zipped) # 与 zip 相反,*zipped 可理解为解压,返回二维矩阵式
102
101
[(1, 2, 3), (4, 5, 6)
103
102
```
104
- * ord
103
+ * ord() 函数是 chr() 函数(对于8位的ASCII字符串)或 unichr() 函数(对于Unicode对象)的配对函数,它以一个字符(长度为1的字符串)作为参数,返回对应的 ASCII 数值,或者 Unicode 数值
104
+ * 进制转换 hex 16进制 # int 10进制 # oct 8进制 # bin 2进制
105
+ * count() 方法用于统计字符串里某个字符或子字符串出现的次数。可选参数为在字符串搜索的开始与结束位置。
106
+ * str.index(substring, beg=0, end=len(string)),
107
+ > substring -- 指定检索的字符串。 beg -- 开始索引,默认为 0。 end -- 结束索引,默认为字符串的长度。
108
+ * [ 字符串处理支持多种操作] ( https://www.runoob.com/python3/python3-string.html )
109
+ * round()保留几位小数 返回浮点数x的四舍五入值。
110
+ * eval()神奇公式: 用来执行一个字符串表达式,并返回表达式的值。
111
+ * OOP
You can’t perform that action at this time.
0 commit comments