Skip to content

Commit 6631f63

Browse files
committed
mod:更新文章
1 parent 88524c8 commit 6631f63

File tree

7 files changed

+163
-1
lines changed

7 files changed

+163
-1
lines changed

Python/images/集合-hash.png

255 KB
Loading

Python/字典.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
## 字典(dict)
2+
3+
> 通常,key叫做键,value叫做值
4+
5+
一组key和value叫做键值对,键值对之间用逗号(,)隔开
6+
7+
```python
8+
{
9+
key1: value1,
10+
key2: value2
11+
}
12+
```
13+
14+
#### 根据key获取对应的value
15+
16+
* d[key]
17+
18+
如果d中不存在这个key,就报错(KeyError)
19+
20+
* d.get(key)
21+
22+
如果d中不存在这个key,就返回None
23+
24+
* d.get(key, x)
25+
26+
如果d中不存在这个key,就返回x
27+
28+
#### 不重复的key
29+
30+
* dict的key 自带去重功能,不会存在2个值相等的key,后面的值会覆盖前面的值
31+
* dict 中允许出现值相等的value
32+
33+
#### 添加修改Key-value
34+
35+
```python
36+
d = {'name': 'GJ'}
37+
d['age'] = 19
38+
d['name'] = 200
39+
=> {'name': 200, 'age': 19}
40+
```
41+
42+
* update 方法
43+
44+
d.update(x)
45+
46+
作用:将 x 中的键值对合并到 d 中
47+
48+
```python
49+
d1 = {'name': 'GJ'}
50+
d2 = {
51+
'age': 19,
52+
'name': '李四'
53+
}
54+
d1.update(d2)
55+
print(d1) => {'name': '李四', 'age': 19}
56+
```
57+
58+
```python
59+
d1 = {'name': 'GJ'}
60+
d2 = {
61+
'age': 19,
62+
'name': '李四'
63+
}
64+
d1.update(d2, name='HH', age=22)
65+
print(d1) => {'name': 'HH', 'age': 22}
66+
```
67+
68+
* setdefault 方法
69+
70+
d.setdefault(key, value)
71+
72+
* 如果d 中不存在这个key,就执行d[key] = value,并返回 value
73+
* 如果d 中存在这个key,就直接返回d[key]
74+
75+
只能添加新的键值对,不能修改已有的键值对
76+
77+
setdeault(key) 等价于 d.setdefault(key, None)
78+
79+
* 如果d中不存在这个key,就执行d[key] = None,并返回None
80+
* 如果d中存在这个key,就直接返回d[key]
81+
82+
#### None
83+
84+
* None:空、没有、不存在
85+
* None值为假
86+
* None值属于NoneType类型
87+
* 用 v is None 判断v是否为None
88+
* 用 v is not None 判断v是否不为 None
89+
90+
#### 创建dict对象
91+
92+
* 创建空字典对象
93+
94+
```python
95+
d1 = {}
96+
```
97+
98+
```python
99+
d2 = dict()
100+
```
101+
102+
```python
103+
d1 = dict(name='GJ', age=20)
104+
print(d1) => {'name': 'GJ', 'age': 20}
105+
```
106+

Python/集合-hash2.png

70.2 KB
Loading

Python/集合.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,33 @@ print(s1) => {33, 11, 44, 22, 55}
3636

3737
* 通常情况下
3838
* 序列类型都是可迭代的
39-
* 可迭代的不一定是序列类型
39+
* 可迭代的不一定是序列类型
40+
41+
#### 常用方法-添加
42+
43+
> set 是可变类型,可以动态添加、删除元素
44+
45+
* s.add(x):添加元素x
46+
* s.discard(x):删除元素x,删除不存在的元素不会报错
47+
* s.remove(x):删除元素x,删除不存在的元素会报错,KeyError
48+
* s.pop(x):删除并返回1个元素,如果集合s的长度为0,会报错(KeyError)
49+
* s.clear():删除集合s中的所有元素
50+
51+
#### 可哈希、不可哈希
52+
53+
* set 中的元素必须都是可哈希的(hashable)
54+
* 不可哈希(unhashable)的对象无法存放到set中
55+
56+
```python
57+
s = {100, False, 3.14, 'GJ', (10, 20, 30), [44, 55, 66]}
58+
print(s) => TypeError: unhashable type: 'list'
59+
```
60+
61+
* 判断一种类型是否可哈希?
62+
* 类型.__ _hash_ _为None,说明不可哈希
63+
* 类型. _ _hash _ _不为None,说明可哈希
64+
* 观察发现,不可变类型往往可哈希,可变类型往往不可哈希
65+
66+
![image-20221219221342522](/Users/guojie/Notes/Python/images/集合-hash.png)
67+
68+
![image-20221219221436271](/Users/guojie/Notes/Python/集合-hash2.png)

杂文/Apple服务查看.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Apple 服务查看
2+
3+
* [地址](https://developer.apple.com/system-status/)

科学方式/2022-11-25-oracle.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ bash <(curl -Ls https://raw.githubusercontent.com/vaxilu/x-ui/master/install.sh)
9797
公钥路径:/root/cert.crt
9898
```
9999

100+
4、当前已经的面板的地址
101+
102+
[X-ui](https://oracle.guoj.xyz:33445/xui/)
103+
104+
[青龙面板](http://144.24.90.47:5700/)
105+
106+
107+
100108
[参考地址](https://github.com/bigdongdongCLUB/GoodGoodStudyDayDayUp/issues/8)
101109

102110
[Bigdongdong的教程](https://www.youtube.com/watch?v=FNhKa9ETr3k&ab_channel=BIGDONGDONG)

科学方式/2022-12-25-replit.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Replit
2+
3+
基于Replit 的方式实现的间接搭建在谷歌云中的VRay协议方式
4+
5+
已经搭建的地址:https://replit.com/@gj9117/V2RAY#qr.png
6+
7+
8+
9+
10+
11+
#### 参考资料
12+
13+
[视频地址](https://www.youtube.com/watch?v=ZsQ6NEZeei0)
14+
15+
[文章地址](https://iweec.com/668.html)
16+

0 commit comments

Comments
 (0)