mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-20 06:01:22 +08:00
Compare commits
44 Commits
Author | SHA1 | Date | |
---|---|---|---|
a4891cef29 | |||
ff0b08acdb | |||
24ea8f6a6a | |||
7900e348f1 | |||
9680e2a113 | |||
a1defb6f23 | |||
af188f9f19 | |||
f6b68c8d09 | |||
252c880f5f | |||
39f16f5a97 | |||
3b6495a781 | |||
8576cbe101 | |||
df4ef8c5ac | |||
e9386b57a5 | |||
8ee2877234 | |||
d5e8643497 | |||
0125cc1c0b | |||
937426be72 | |||
de964317cd | |||
fdb5b72830 | |||
4039d6f04c | |||
2a6da92c94 | |||
c5c157ea3d | |||
51fb218d6b | |||
150208884f | |||
c44ace5edd | |||
e97a1a8f8a | |||
3451e3b055 | |||
3cc761446e | |||
cfbe8ae4b8 | |||
9df9ff4354 | |||
cf7e9aa29e | |||
a38aaccd49 | |||
4d813c765f | |||
3d1abf5035 | |||
f7b60c9a09 | |||
93f1b473af | |||
c35662155e | |||
f3692146bf | |||
f0135c77a1 | |||
8aed2170e3 | |||
c4308aac0f | |||
82c0e32a16 | |||
80ac14cad6 |
@ -1,6 +1,5 @@
|
||||
.github
|
||||
.husky
|
||||
docs
|
||||
scripts
|
||||
node_modules
|
||||
package-lock.json
|
||||
|
@ -234,6 +234,9 @@ jobs:
|
||||
<a href="https://github.com/eryajf" title="二丫讲梵">
|
||||
<img src="https://avatars.githubusercontent.com/u/33259379?v=4" width="42;" alt="二丫讲梵"/>
|
||||
</a>
|
||||
<a href="https://github.com/heStudio-Network" title="醉、倾城">
|
||||
<img src="https://avatars.githubusercontent.com/u/119711513?v=4" width="42;" alt="醉、倾城"/>
|
||||
</a>
|
||||
<a href="https://github.com/LiuYuan-SHU" title="Yuan Liu">
|
||||
<img src="https://avatars.githubusercontent.com/u/96400967?v=4" width="42;" alt="Yuan Liu"/>
|
||||
</a>
|
||||
@ -246,8 +249,8 @@ jobs:
|
||||
<a href="https://github.com/qyl27" title="秋 雨落">
|
||||
<img src="https://avatars.githubusercontent.com/u/53731501?v=4" width="42;" alt="秋 雨落"/>
|
||||
</a>
|
||||
<a href="https://github.com/heStudio-Network" title="醉、倾城">
|
||||
<img src="https://avatars.githubusercontent.com/u/119711513?v=4" width="42;" alt="醉、倾城"/>
|
||||
<a href="https://github.com/dadatom" title="Da Da">
|
||||
<img src="https://avatars.githubusercontent.com/u/33886943?v=4" width="42;" alt="Da Da"/>
|
||||
</a>
|
||||
<a href="https://github.com/XYZscratcher" title="XYZ">
|
||||
<img src="https://avatars.githubusercontent.com/u/108533817?v=4" width="42;" alt="XYZ"/>
|
||||
@ -270,6 +273,9 @@ jobs:
|
||||
<a href="https://github.com/catcto" title="喵仙人">
|
||||
<img src="https://avatars.githubusercontent.com/u/5467932?v=4" width="42;" alt="喵仙人"/>
|
||||
</a>
|
||||
<a href="https://github.com/itldg" title="老大哥">
|
||||
<img src="https://avatars.githubusercontent.com/u/13432299?v=4" width="42;" alt="老大哥"/>
|
||||
</a>
|
||||
<a href="https://github.com/Country-If" title="Maylon">
|
||||
<img src="https://avatars.githubusercontent.com/u/62837275?v=4" width="42;" alt="Maylon"/>
|
||||
</a>
|
||||
@ -291,6 +297,9 @@ jobs:
|
||||
<a href="https://github.com/Damao2250" title="Damao">
|
||||
<img src="https://avatars.githubusercontent.com/u/19251992?v=4" width="42;" alt="Damao"/>
|
||||
</a>
|
||||
<a href="https://github.com/dasferco" title="Dasferco">
|
||||
<img src="https://avatars.githubusercontent.com/u/92622404?v=4" width="42;" alt="Dasferco"/>
|
||||
</a>
|
||||
<a href="https://github.com/demigodliu" title="DemigodLiu">
|
||||
<img src="https://avatars.githubusercontent.com/u/30372735?v=4" width="42;" alt="DemigodLiu"/>
|
||||
</a>
|
||||
@ -345,9 +354,15 @@ jobs:
|
||||
<a href="https://github.com/PipecraftNet" title="Pipecraft">
|
||||
<img src="https://avatars.githubusercontent.com/u/88728670?v=4" width="42;" alt="Pipecraft"/>
|
||||
</a>
|
||||
<a href="https://github.com/sevenleave" title="Poirot Hercule">
|
||||
<img src="https://avatars.githubusercontent.com/u/24411140?v=4" width="42;" alt="Poirot Hercule"/>
|
||||
</a>
|
||||
<a href="https://github.com/QDelta" title="QDelta">
|
||||
<img src="https://avatars.githubusercontent.com/u/60222316?v=4" width="42;" alt="QDelta"/>
|
||||
</a>
|
||||
<a href="https://github.com/RivailleF" title="RivailleF">
|
||||
<img src="https://avatars.githubusercontent.com/u/93083015?v=4" width="42;" alt="RivailleF"/>
|
||||
</a>
|
||||
<a href="https://github.com/qinxiongzhou" title="Ryan Zhou">
|
||||
<img src="https://avatars.githubusercontent.com/u/33239096?v=4" width="42;" alt="Ryan Zhou"/>
|
||||
</a>
|
||||
@ -408,6 +423,9 @@ jobs:
|
||||
<a href="https://github.com/sunny0826" title="Xudong Guo">
|
||||
<img src="https://avatars.githubusercontent.com/u/24563928?v=4" width="42;" alt="Xudong Guo"/>
|
||||
</a>
|
||||
<a href="https://github.com/gzttcydxx" title="gzttcydxx">
|
||||
<img src="https://avatars.githubusercontent.com/u/50025185?v=4" width="42;" alt="gzttcydxx"/>
|
||||
</a>
|
||||
<a href="https://github.com/hua03" title="hua03">
|
||||
<img src="https://avatars.githubusercontent.com/u/19561959?v=4" width="42;" alt="hua03"/>
|
||||
</a>
|
||||
@ -477,6 +495,9 @@ jobs:
|
||||
<a href="https://github.com/ZIDOUZI" title="子斗子">
|
||||
<img src="https://avatars.githubusercontent.com/u/53157536?v=4" width="42;" alt="子斗子"/>
|
||||
</a>
|
||||
<a href="https://github.com/aixcyi" title="砹小翼">
|
||||
<img src="https://avatars.githubusercontent.com/u/75880483?v=4" width="42;" alt="砹小翼"/>
|
||||
</a>
|
||||
<a href="https://github.com/lisheng741" title="芦荟柚子茶">
|
||||
<img src="https://avatars.githubusercontent.com/u/53617305?v=4" width="42;" alt="芦荟柚子茶"/>
|
||||
</a>
|
||||
|
31
README.md
31
README.md
@ -249,6 +249,9 @@ Quick Reference
|
||||
<a href="https://github.com/eryajf" title="二丫讲梵">
|
||||
<img src="https://avatars.githubusercontent.com/u/33259379?v=4" width="42;" alt="二丫讲梵"/>
|
||||
</a>
|
||||
<a href="https://github.com/heStudio-Network" title="醉、倾城">
|
||||
<img src="https://avatars.githubusercontent.com/u/119711513?v=4" width="42;" alt="醉、倾城"/>
|
||||
</a>
|
||||
<a href="https://github.com/LiuYuan-SHU" title="Yuan Liu">
|
||||
<img src="https://avatars.githubusercontent.com/u/96400967?v=4" width="42;" alt="Yuan Liu"/>
|
||||
</a>
|
||||
@ -261,8 +264,8 @@ Quick Reference
|
||||
<a href="https://github.com/qyl27" title="秋 雨落">
|
||||
<img src="https://avatars.githubusercontent.com/u/53731501?v=4" width="42;" alt="秋 雨落"/>
|
||||
</a>
|
||||
<a href="https://github.com/heStudio-Network" title="醉、倾城">
|
||||
<img src="https://avatars.githubusercontent.com/u/119711513?v=4" width="42;" alt="醉、倾城"/>
|
||||
<a href="https://github.com/dadatom" title="Da Da">
|
||||
<img src="https://avatars.githubusercontent.com/u/33886943?v=4" width="42;" alt="Da Da"/>
|
||||
</a>
|
||||
<a href="https://github.com/XYZscratcher" title="XYZ">
|
||||
<img src="https://avatars.githubusercontent.com/u/108533817?v=4" width="42;" alt="XYZ"/>
|
||||
@ -285,6 +288,9 @@ Quick Reference
|
||||
<a href="https://github.com/catcto" title="喵仙人">
|
||||
<img src="https://avatars.githubusercontent.com/u/5467932?v=4" width="42;" alt="喵仙人"/>
|
||||
</a>
|
||||
<a href="https://github.com/itldg" title="老大哥">
|
||||
<img src="https://avatars.githubusercontent.com/u/13432299?v=4" width="42;" alt="老大哥"/>
|
||||
</a>
|
||||
<a href="https://github.com/Country-If" title="Maylon">
|
||||
<img src="https://avatars.githubusercontent.com/u/62837275?v=4" width="42;" alt="Maylon"/>
|
||||
</a>
|
||||
@ -306,6 +312,9 @@ Quick Reference
|
||||
<a href="https://github.com/Damao2250" title="Damao">
|
||||
<img src="https://avatars.githubusercontent.com/u/19251992?v=4" width="42;" alt="Damao"/>
|
||||
</a>
|
||||
<a href="https://github.com/dasferco" title="Dasferco">
|
||||
<img src="https://avatars.githubusercontent.com/u/92622404?v=4" width="42;" alt="Dasferco"/>
|
||||
</a>
|
||||
<a href="https://github.com/demigodliu" title="DemigodLiu">
|
||||
<img src="https://avatars.githubusercontent.com/u/30372735?v=4" width="42;" alt="DemigodLiu"/>
|
||||
</a>
|
||||
@ -360,9 +369,15 @@ Quick Reference
|
||||
<a href="https://github.com/PipecraftNet" title="Pipecraft">
|
||||
<img src="https://avatars.githubusercontent.com/u/88728670?v=4" width="42;" alt="Pipecraft"/>
|
||||
</a>
|
||||
<a href="https://github.com/sevenleave" title="Poirot Hercule">
|
||||
<img src="https://avatars.githubusercontent.com/u/24411140?v=4" width="42;" alt="Poirot Hercule"/>
|
||||
</a>
|
||||
<a href="https://github.com/QDelta" title="QDelta">
|
||||
<img src="https://avatars.githubusercontent.com/u/60222316?v=4" width="42;" alt="QDelta"/>
|
||||
</a>
|
||||
<a href="https://github.com/RivailleF" title="RivailleF">
|
||||
<img src="https://avatars.githubusercontent.com/u/93083015?v=4" width="42;" alt="RivailleF"/>
|
||||
</a>
|
||||
<a href="https://github.com/qinxiongzhou" title="Ryan Zhou">
|
||||
<img src="https://avatars.githubusercontent.com/u/33239096?v=4" width="42;" alt="Ryan Zhou"/>
|
||||
</a>
|
||||
@ -423,6 +438,9 @@ Quick Reference
|
||||
<a href="https://github.com/sunny0826" title="Xudong Guo">
|
||||
<img src="https://avatars.githubusercontent.com/u/24563928?v=4" width="42;" alt="Xudong Guo"/>
|
||||
</a>
|
||||
<a href="https://github.com/gzttcydxx" title="gzttcydxx">
|
||||
<img src="https://avatars.githubusercontent.com/u/50025185?v=4" width="42;" alt="gzttcydxx"/>
|
||||
</a>
|
||||
<a href="https://github.com/hua03" title="hua03">
|
||||
<img src="https://avatars.githubusercontent.com/u/19561959?v=4" width="42;" alt="hua03"/>
|
||||
</a>
|
||||
@ -492,6 +510,9 @@ Quick Reference
|
||||
<a href="https://github.com/ZIDOUZI" title="子斗子">
|
||||
<img src="https://avatars.githubusercontent.com/u/53157536?v=4" width="42;" alt="子斗子"/>
|
||||
</a>
|
||||
<a href="https://github.com/aixcyi" title="砹小翼">
|
||||
<img src="https://avatars.githubusercontent.com/u/75880483?v=4" width="42;" alt="砹小翼"/>
|
||||
</a>
|
||||
<a href="https://github.com/lisheng741" title="芦荟柚子茶">
|
||||
<img src="https://avatars.githubusercontent.com/u/53617305?v=4" width="42;" alt="芦荟柚子茶"/>
|
||||
</a>
|
||||
@ -526,7 +547,7 @@ Quick Reference
|
||||
[linzhe.top](https://linzhe.top/)<!--rehype:target=_blank-->
|
||||
[xushanxiang.com](https://xushanxiang.com/ref/)<!--rehype:target=_blank-->
|
||||
[winnerzr01.github.io](https://winnerzr01.github.io/Quick-Reference/index.html)<!--rehype:target=_blank&class=contributing&data-info=👆需要梯子-->
|
||||
[hestudio.org](https://quickref.hestudio.org)<!--rehype:target=_blank&class=contributing&data-info=👆整点自动同步-->
|
||||
[quickref.hestudio.net](https://quickref.hestudio.net)<!--rehype:target=_blank&class=contributing&data-info=👆整点自动同步-->
|
||||
[surcode.cn](https://ref.surcode.cn)<!--rehype:target=_blank-->
|
||||
[cms.im](https://quickref.cms.im/)<!--rehype:target=_blank-->
|
||||
[nuomiphp.com](https://reference.tool.nuomiphp.com/)<!--rehype:target=_blank-->
|
||||
@ -554,6 +575,10 @@ Quick Reference
|
||||
[qirishuzhai.com](http://qirishuzhai.com/quickref)<!--rehype:target=_blank-->
|
||||
[longdada.me](https://ref.longdada.me)<!--rehype:target=_blank-->
|
||||
[xalaok.top](https://ref.xalaok.top)<!--rehype:target=_blank-->
|
||||
[dadatom.com](https://tools.dadatom.com/reference/)<!--rehype:target=_blank&class=contributing&data-info=👆支持ipv4和ipv6-->
|
||||
[zhangyuanqian.top](https://reference.zhangyuanqian.top/)<!--rehype:target=_blank-->
|
||||
[sosloli.com](https://ref.sosloli.com)<!--rehype:target=_blank-->
|
||||
[chenze.cloud](https://quick.chenze.cloud)<!--rehype:target=_blank-->
|
||||
<!--rehype:class=home-card home-links-->
|
||||
|
||||
如果你有资源,可以很方便[部署 web 版](https://github.com/jaywcjlove/reference/issues/102#issue-1451649637),这非常简单,只需要克隆 [gh-pages](https://github.com/jaywcjlove/reference/tree/gh-pages) 分支代码到你的静态服务就可以了,还可以使用 [docker](https://hub.docker.com/r/wcjiang/reference) 快捷部署 web 版。
|
||||
|
@ -19,6 +19,7 @@ Ansible 备忘清单
|
||||
- [Ansible 官方文档](https://docs.ansible.com)
|
||||
|
||||
### 配置位置
|
||||
<!--rehype:wrap-class=col-span-2 row-span-2-->
|
||||
|
||||
文件路径 | 说明
|
||||
:-|-
|
||||
@ -26,13 +27,27 @@ Ansible 备忘清单
|
||||
`~/ansible.cfg` | 用户特定的配置
|
||||
`$pwd/ansible.cfg` | 当前目录下的配置
|
||||
|
||||
配置文件优先级
|
||||
|
||||
- 如果没有任何其他配置文件,默认使用 `/etc/ansible/ansible.cfg`
|
||||
- `~/.ansible.cfg` `家`目录下的 `.ansible.cfg`
|
||||
- 当前目录下的 `ansible.cfg`,即在同一目录下 `ansible.cfg` 优先级高于 `~/.ansible.cfg`
|
||||
- 环境变量 `exoport ANSIBLE_CONFIG=/$DIR/ansible.cfg`
|
||||
<!--rehype:className=style-timeline-->
|
||||
|
||||
查看正在使用的 `ansible` 配置文件:
|
||||
|
||||
```bash
|
||||
ansible --version | grep "config file"
|
||||
```
|
||||
|
||||
### Inventory文件(hosts列表)
|
||||
|
||||
#### 静态Inventory
|
||||
|
||||
`/etc/ansible/hosts`
|
||||
|
||||
```INI
|
||||
```ini
|
||||
mail.example.com
|
||||
|
||||
[webservers]
|
||||
@ -42,7 +57,7 @@ bar.example.com
|
||||
|
||||
### Inventory 主机组使用多个IP和域名
|
||||
|
||||
```
|
||||
```ini
|
||||
[web]
|
||||
172.18.12.5[1:4]
|
||||
[webservers]
|
||||
|
75
docs/cs.md
75
docs/cs.md
@ -155,6 +155,24 @@ foreach(int num in numbers) {
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```cs
|
||||
while(true)
|
||||
{
|
||||
Console.WriteLine("只要给定的条件为真,while 循环语句会重复执行");
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```cs
|
||||
do
|
||||
{
|
||||
Console.WriteLine("与 while 类似,do...while 会确保至少执行一次循环。");
|
||||
} while( true );
|
||||
```
|
||||
|
||||
C# 数据类型
|
||||
---------------------
|
||||
|
||||
@ -341,6 +359,63 @@ null | false | false | null | null | null
|
||||
null | null | null | null | null | null
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
### 算术运算符
|
||||
<!--rehype:wrap-class=col-span-1-->
|
||||
|
||||
C# 支持下表中的所有算术运算符。假设变量 A 的值为 10,变量 B 的值为 20,则:
|
||||
|
||||
| 运算符 | 描述 | 实例 |
|
||||
| :----- | -------------------------------- | ----------------- |
|
||||
| + | 把两个操作数相加 | A + B 将得到 30 |
|
||||
| - | 从第一个操作数中减去第二个操作数 | A - B 将得到 -10 |
|
||||
| \* | 把两个操作数相乘 | A \* B 将得到 200 |
|
||||
| / | 分子除以分母 | B / A 将得到 2 |
|
||||
| % | 取模运算符,整除后的余数 | B % A 将得到 0 |
|
||||
| ++ | 自增运算符,整数值增加 1 | A++ 将得到 11 |
|
||||
| -- | 自减运算符,整数值减少 1 | A-- 将得到 9 |
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
### 关系运算符
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
C# 支持下表中的所有关系运算符。假设变量 A 的值为 1,变量 B 的值为 2,则:
|
||||
|
||||
| 运算符 | 描述 | 实例 |
|
||||
| :----- | -------------------------------------------------------------- | ----------------- |
|
||||
| == | 检查两个操作数的值是否相等,如果相等则条件为真。 | (A == B) 不为真。 |
|
||||
| != | 检查两个操作数的值是否相等,如果不相等则条件为真。 | (A != B) 为真。 |
|
||||
| > | 检查左操作数的值是否大于右操作数的值,如果是则条件为真。 | (A > B) 不为真。 |
|
||||
| < | 检查左操作数的值是否小于右操作数的值,如果是则条件为真。 | (A < B) 为真。 |
|
||||
| >= | 检查左操作数的值是否大于或等于右操作数的值,如果是则条件为真。 | (A >= B) 不为真。 |
|
||||
| <= | 检查左操作数的值是否小于或等于右操作数的值,如果是则条件为真。 | (A <= B) 为真。 |
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
### 运算符优先级
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
|
||||
运算符的优先级确定表达式中项的组合。这会影响到一个表达式如何计算。某些运算符比其他运算符有更高的优先级,例如,乘除运算符具有比加减运算符更高的优先级。
|
||||
|
||||
下表将按运算符优先级从高到低列出各个运算符,具有较高优先级的运算符出现在表格的上面,具有较低优先级的运算符出现在表格的下面。在表达式中,较高优先级的运算符会优先被计算。
|
||||
|
||||
| 类别 | 运算符 | 结合性 |
|
||||
| :--------- | ---------------------------------- | -------- |
|
||||
| 后缀 | () [] -> . ++ - - | 从左到右 |
|
||||
| 一元 | + - ! ~ ++ - - (type)\* & sizeof | 从右到左 |
|
||||
| 乘除 | \* / % | 从左到右 |
|
||||
| 加减 | + - | 从左到右 |
|
||||
| 移位 | << >> | 从左到右 |
|
||||
| 关系 | < <= > >= | 从左到右 |
|
||||
| 相等 | == != | 从左到右 |
|
||||
| 位与 AND | & | 从左到右 |
|
||||
| 位异或 XOR | ^ | 从左到右 |
|
||||
| 位或 OR | \| | 从左到右 |
|
||||
| 逻辑与 AND | && | 从左到右 |
|
||||
| 逻辑或 OR | \|\| | 从左到右 |
|
||||
| 条件 | ?: | 从右到左 |
|
||||
| 赋值 | = += -= \*= /= %=>>= <<= &= ^= \|= | 从右到左 |
|
||||
| 逗号 | , | 从左到右 |
|
||||
<!--rehype:className=show-header-->
|
||||
|
||||
杂项
|
||||
-----------
|
||||
|
||||
|
@ -980,3 +980,16 @@ Github emoji 图标标记
|
||||
| :milky_way: | `:milky_way:` |
|
||||
| :partly_sunny: | `:partly_sunny:` |
|
||||
| :carrot: | `:carrot:` |
|
||||
|
||||
另见
|
||||
--------
|
||||
|
||||
- [Emoji searcher](https://emoji.muan.co/) _(muan.co)_
|
||||
- [Get Emoji — All Emojis to ✂️ Copy and 📋 Paste](https://getemoji.com/) _(getemoji.com)_
|
||||
- [Emoji Guide – 🔥 The Ultimate Emoji Guide: 🌈 Meanings, 🍎 Platforms, 🆘 Codes and 😍 More](https://emojiguide.com/) _(emojiguide.com)_
|
||||
- [Full Emoji List, v15.0](https://unicode.org/emoji/charts/full-emoji-list.html) _(unicode.org)_
|
||||
- [Emoji Cheat Sheet](https://www.webfx.com/tools/emoji-cheat-sheet/) _(webfx.com)_
|
||||
- [EmojiCopy | Simple emoji copy and paste keyboard by JoyPixels®](https://www.emojicopy.com/) _(emojicopy.com)_
|
||||
- [Emojis 🌱☀️ - Copy & Paste Online 🕵️♀️ | Quicktools by Picsart](https://tools.picsart.com/text/emojis/) _(tools.picsart.com)_
|
||||
- [Emojihub 😀 - All Emojis To Copy And Paste](https://emojihub.org/) _(emojihub.org)_
|
||||
- [All Emojis – Emoji List for Copy and Paste](https://www.freecodecamp.org/news/all-emojis-emoji-list-for-copy-and-paste/) _(freecodecamp.org)_
|
||||
|
@ -27,7 +27,7 @@ Google Chrome 键盘快捷键备忘清单
|
||||
`Alt` `Space` `N` | 最小化当前窗口
|
||||
`Alt` `Space` `X` | 最大化当前窗口
|
||||
`Alt` `F4` | 关闭当前窗口
|
||||
`Ctrl` `Shift` `Q` | 相当谷歌浏览器
|
||||
`Ctrl` `Shift` `Q` | 退出谷歌浏览器
|
||||
<!--rehype:className=shortcuts-->
|
||||
|
||||
### 谷歌浏览器功能
|
||||
|
@ -37,7 +37,7 @@ file="acme payroll.dat"
|
||||
name = value
|
||||
```
|
||||
|
||||
与下面👇 JSON 大致相同
|
||||
与下面👇 `JSON` 大致相同
|
||||
|
||||
```js
|
||||
{
|
||||
|
@ -969,4 +969,4 @@ echo 'CURRENT_DATE is: ' . CURRENT_DATE;
|
||||
----
|
||||
|
||||
- [PHP 官方中文文档](https://www.php.net/manual/zh/index.php) _(php.net)_
|
||||
- [Learn X in Y minutes](https://learnxinyminutes.com/docs/php/) _(learnxinyminutes.com)_
|
||||
- [Learn X in Y minutes](https://learnxinyminutes.com/docs/zh-cn/php-cn/) _(learnxinyminutes.com)_
|
||||
|
183
docs/python.md
183
docs/python.md
@ -9,6 +9,7 @@ Python 备忘单是 [Python 3](https://www.python.org/) 编程语言的单页参
|
||||
### 介绍
|
||||
|
||||
- [Python](https://www.python.org/) _(python.org)_
|
||||
- [Python 文档](https://docs.python.org/zh-cn/3/index.html) _(docs.python.org)_
|
||||
- [Learn X in Y minutes](https://learnxinyminutes.com/docs/python/) _(learnxinyminutes.com)_
|
||||
- [Regex in python](./regex.md#python-中的正则表达式) _(jaywcjlove.github.io)_
|
||||
|
||||
@ -877,6 +878,8 @@ def varargs(*args):
|
||||
varargs(1, 2, 3) # => (1, 2, 3)
|
||||
```
|
||||
|
||||
args 的类型是 tuple
|
||||
|
||||
### 关键字参数
|
||||
|
||||
```python
|
||||
@ -886,6 +889,8 @@ def keyword_args(**kwargs):
|
||||
keyword_args(big="foot", loch="ness")
|
||||
```
|
||||
|
||||
kwargs 的类型是 dict
|
||||
|
||||
### 返回多个
|
||||
|
||||
```python
|
||||
@ -1182,6 +1187,182 @@ print(Yoki.legs) # => 4
|
||||
Yoki.sound() # => Woof!
|
||||
```
|
||||
|
||||
Python 类型标注 (自 Python 3.5 起)
|
||||
--------
|
||||
|
||||
### 变量
|
||||
|
||||
```python
|
||||
string: str = "ha"
|
||||
times: int = 3
|
||||
|
||||
print(string * times) # => hahaha
|
||||
```
|
||||
|
||||
### 变量
|
||||
|
||||
```python
|
||||
result: int = 1 + 2
|
||||
|
||||
print(result) # => 3
|
||||
```
|
||||
|
||||
虽然标注了错误的类型,但不影响正常运行
|
||||
|
||||
### 参数
|
||||
|
||||
```python
|
||||
def say(name: str, start: str = "Hi"):
|
||||
return start + ", " + name
|
||||
|
||||
print(say("Python")) # => Hi, Python
|
||||
```
|
||||
|
||||
### 位置参数
|
||||
|
||||
```python
|
||||
def calc_summary(*args: int):
|
||||
return sum(args)
|
||||
|
||||
print(calc_summary(3, 1, 4)) # => 8
|
||||
```
|
||||
|
||||
表示 args 的所有元素都是 int 类型的。
|
||||
|
||||
### 返回值
|
||||
|
||||
```python
|
||||
def say_hello(name) -> str:
|
||||
return "Hello, " + name
|
||||
|
||||
var = "Python"
|
||||
print(say_hello(var)) # => Hello, Python
|
||||
```
|
||||
|
||||
### 多种可能的返回值
|
||||
|
||||
```python
|
||||
from typing import Union
|
||||
|
||||
def resp200(meaningful) -> Union[int, str]:
|
||||
return "OK" if meaningful else 200
|
||||
```
|
||||
|
||||
表示返回值可能是 int,也可能是 str 。
|
||||
|
||||
### 关键字参数
|
||||
|
||||
```python
|
||||
def calc_summary(**kwargs: int):
|
||||
return sum(kwargs.values())
|
||||
|
||||
print(calc_summary(a=1, b=2)) # => 3
|
||||
```
|
||||
|
||||
表示 kwargs 的所有值都是 int 类型的。
|
||||
|
||||
### 多个返回值
|
||||
|
||||
```python
|
||||
def resp200() -> (int, str):
|
||||
return 200, "OK"
|
||||
```
|
||||
|
||||
### 多种可能的返回值 (3.10+)
|
||||
|
||||
```python
|
||||
def resp200(meaningful) -> int | str:
|
||||
return "OK" if meaningful else 200
|
||||
```
|
||||
|
||||
自 Python 3.10 起可用。
|
||||
|
||||
### 属性
|
||||
|
||||
```python
|
||||
class Employee:
|
||||
name: str
|
||||
age: int
|
||||
|
||||
def __init__(self, name, age):
|
||||
self.name = name
|
||||
self.age = age
|
||||
self.graduated: bool = False
|
||||
```
|
||||
|
||||
### 标注自己
|
||||
|
||||
```python
|
||||
class Employee:
|
||||
name: str
|
||||
age: int
|
||||
|
||||
def set_name(self, name) -> "Employee":
|
||||
self.name = name
|
||||
return self
|
||||
```
|
||||
|
||||
这里表示 set_name() 返回了一个 Employee 对象。
|
||||
|
||||
### 标注自己 (3.11+)
|
||||
|
||||
```python
|
||||
from typing import Self
|
||||
|
||||
class Employee:
|
||||
name: str
|
||||
age: int
|
||||
|
||||
def set_name(self: Self, name) -> Self:
|
||||
self.name = name
|
||||
return self
|
||||
```
|
||||
|
||||
### 标注一个值为类型的参数
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
```python
|
||||
from typing import TypeVar, Type
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
# "mapper" 的值是一个像 int、str、MyClass 这样的类型
|
||||
# "default" 是一个 T 类型的值,比如 314、"string"、MyClass()
|
||||
# 函数的返回值也是一个 T 类型的值
|
||||
def converter(raw, mapper: Type[T], default: T) -> T:
|
||||
try:
|
||||
return mapper(raw)
|
||||
except:
|
||||
return default
|
||||
|
||||
raw: str = input("请输入一个整数:")
|
||||
result: int = converter(raw, mapper=int, default=0)
|
||||
```
|
||||
|
||||
### 标注一个值为函数的参数
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```python
|
||||
from typing import TypeVar, Callable, Any
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
def converter(raw, mapper: Callable[[Any], T], default: T) -> T:
|
||||
try:
|
||||
return mapper(raw)
|
||||
except:
|
||||
return default
|
||||
|
||||
# Callable[[Any], T] 表示值是一个像这样声明的函数:
|
||||
# def anynomous(arg: Any) -> T:
|
||||
# pass
|
||||
|
||||
def is_success(value) -> bool:
|
||||
return value in (0, "OK", True, "success")
|
||||
|
||||
resp = dict(code=0, message="OK", data=[])
|
||||
successed: bool = converter(resp.message, mapper=is_success, default=False)
|
||||
```
|
||||
|
||||
各种各样的
|
||||
----------
|
||||
|
||||
@ -1249,5 +1430,5 @@ finally: # 在所有情况下执行
|
||||
----
|
||||
|
||||
- [Python](https://www.python.org/) _(python.org)_
|
||||
- [Learn X in Y minutes](https://learnxinyminutes.com/docs/python/) _(learnxinyminutes.com)_
|
||||
- [Learn X in Y minutes](https://learnxinyminutes.com/docs/zh-cn/python-cn/) _(learnxinyminutes.com)_
|
||||
- [Regex in python](./regex.md#python-中的正则表达式) _(jaywcjlove.github.io)_
|
||||
|
@ -110,7 +110,7 @@ class=tag&data-info=👆看看还缺点儿什么?
|
||||
|
||||
添加 `class=tag&data-lang=Python` 类名和参数,会在卡片右上角标记 _`Python`_
|
||||
|
||||
### Command Help
|
||||
### 命令帮助
|
||||
|
||||
```bash
|
||||
Usage: refs-cli [output-dir] [--help|h]
|
||||
@ -135,7 +135,9 @@ Example:
|
||||
refs-cli@v0.0.1
|
||||
```
|
||||
|
||||
### Config
|
||||
### 配置 Config
|
||||
|
||||
将 `.refsrc.json` 存放在项目的根目录下
|
||||
|
||||
```json
|
||||
{
|
||||
@ -163,7 +165,55 @@ refs-cli@v0.0.1
|
||||
}
|
||||
```
|
||||
|
||||
将 `.refsrc.json` 存放在项目的根目录下
|
||||
支持 [JSON](https://www.json.org), [JSONC](https://github.com/microsoft/node-jsonc-parser), [JSON5](https://json5.org/), [YAML](https://yaml.org/), [TOML](https://toml.io), [INI](https://en.wikipedia.org/wiki/INI_file), [CJS](http://www.commonjs.org), [Typescript](https://www.typescriptlang.org/), 和 ESM 配置加载。
|
||||
|
||||
### `TOML` 配置示例
|
||||
|
||||
将 `.refsrc.toml` 存放在项目的根目录下
|
||||
|
||||
```toml
|
||||
title = "Refs CLI 文档网站名称"
|
||||
description = "{{description}}. 网站说明"
|
||||
keywords = "关键字,reference,refs-cli,cli"
|
||||
data-info = "👆 需要你的参与"
|
||||
|
||||
[search]
|
||||
label = "搜索"
|
||||
placeholder = "搜索备忘清单"
|
||||
cancel = "取消"
|
||||
|
||||
[editor]
|
||||
label = "编辑"
|
||||
|
||||
[github]
|
||||
url = "<github url>"
|
||||
|
||||
[home]
|
||||
label = "首页"
|
||||
url = "https://<你的网站>"
|
||||
|
||||
footer = "<br />备案号:支持HTML字符串"
|
||||
license = "支持 HTML 字符串"
|
||||
```
|
||||
|
||||
### 支持更多配置加载
|
||||
|
||||
```bash
|
||||
.refsrc .refsrc.json
|
||||
.refsrc.json5 .refsrc.jsonc
|
||||
.refsrc.yaml .refsrc.yml
|
||||
.refsrc.toml .refsrc.ini
|
||||
.refsrc.js .refsrc.ts
|
||||
.refsrc.cjs .refsrc.mjs
|
||||
.config/refsrc .config/refsrc.json
|
||||
.config/refsrc.json5 .config/refsrc.jsonc
|
||||
.config/refsrc.yaml .config/refsrc.yml
|
||||
.config/refsrc.toml .config/refsrc.ini
|
||||
.config/refsrc.js .config/refsrc.ts
|
||||
.config/refsrc.cjs .config/refsrc.mjs
|
||||
refs.config.js refs.config.ts
|
||||
refs.config.cjs refs.config.mjs
|
||||
```
|
||||
|
||||
### 环境变量
|
||||
|
||||
|
@ -1185,17 +1185,17 @@ function Dog(prop:CeProps): JSX.Element {
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
|
||||
```tsx
|
||||
interface MenuProps extends React.LiHTMLAttributes<HTMLUListElement> { ... }
|
||||
const InternalMenu = (props: MenuProps, ref?: React.ForwardedRef<HTMLUListElement>) => (
|
||||
interface MenuProps extends React.LiHTMLAttributes<HTMLUListElement> { ... };
|
||||
const InternalMenu = React.forwardRef<HTMLUListElement, MenuProps>((props, ref) => (
|
||||
<ul {...props} ref={ref} />
|
||||
);
|
||||
type MenuComponent = React.FC<React.PropsWithRef<MenuProps>> & {
|
||||
));
|
||||
|
||||
type MenuComponent = typeof InternalMenu & {
|
||||
Item: typeof MenuItem; // MenuItem 函数组件
|
||||
SubMenu: typeof SubMenu; // SubMenu 函数组件
|
||||
};
|
||||
const Menu: MenuComponent = React.forwardRef<HTMLUListElement>(
|
||||
InternalMenu
|
||||
) as unknown as MenuComponent;
|
||||
|
||||
const Menu: MenuComponent = InternalMenu as unknown as MenuComponent;
|
||||
|
||||
Menu.Item = MenuItem;
|
||||
Menu.SubMenu = SubMenu;
|
||||
@ -1312,13 +1312,16 @@ type SomeBigInt = "100" extends `${infer U extends bigint}` ? U : never;
|
||||
### keyof 取 interface 的键
|
||||
|
||||
```ts
|
||||
interface Point {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
interface Point { x: number; y: number; }
|
||||
|
||||
// type keys = "x" | "y"
|
||||
type keys = keyof Point;
|
||||
|
||||
type Arrayish = {
|
||||
[n: number]: unknown;
|
||||
};
|
||||
type A = keyof Arrayish;
|
||||
// type A = number
|
||||
```
|
||||
|
||||
### 索引签名
|
||||
@ -1394,7 +1397,8 @@ const redComponent = palette.red.at(0)
|
||||
不使用的情况下:
|
||||
|
||||
```ts
|
||||
const errorMap: Map<string, Error> = new Map()
|
||||
const errorMap: Map<string, Error>
|
||||
= new Map()
|
||||
// 或者使用 type 定义别名
|
||||
type ErrorMapType = Map<string, Error>
|
||||
```
|
||||
@ -1423,7 +1427,8 @@ function makeHammerBox(hammer: Hammer) {
|
||||
return makeBox(hammer);
|
||||
}
|
||||
// or...
|
||||
const makeWrenchBox: (wrench: Wrench) => Box<Wrench> = makeBox;
|
||||
const makeWrenchBox: (wrench: Wrench)
|
||||
=> Box<Wrench> = makeBox;
|
||||
```
|
||||
|
||||
使用:
|
||||
@ -1446,6 +1451,28 @@ export interface FancyOption {
|
||||
}
|
||||
```
|
||||
|
||||
### 获取数组元素的类型
|
||||
|
||||
```ts
|
||||
const MyArray = [
|
||||
{ name: "Alice", age: 15 },
|
||||
{ name: "Bob", age: 23 },
|
||||
{ name: "Eve", age: 38 },
|
||||
];
|
||||
|
||||
type Person = typeof MyArray[number];
|
||||
// type Person = {
|
||||
// name: string;
|
||||
// age: number;
|
||||
// }
|
||||
|
||||
type Age = typeof MyArray[number]["age"];
|
||||
// type Age = number
|
||||
|
||||
type Age2 = Person["age"];
|
||||
// type Age2 = number
|
||||
```
|
||||
|
||||
.d.ts 模版
|
||||
---
|
||||
|
||||
|
@ -520,7 +520,7 @@ YAML 参考
|
||||
---
|
||||
|
||||
- [YAML Reference Card](https://yaml.org/refcard.html) _(yaml.org)_
|
||||
- [Learn X in Y minutes](https://learnxinyminutes.com/docs/yaml/) _(learnxinyminutes.com)_
|
||||
- [Learn X in Y minutes](https://learnxinyminutes.com/docs/zh-cn/yaml-cn/) _(learnxinyminutes.com)_
|
||||
- [YAML lint online](http://www.yamllint.com/) _(yamllint.com)_
|
||||
- [INI 格式配置文件备忘清单](./ini.md) _(jaywcjlove.github.io)_
|
||||
- [TOML 格式配置文件备忘清单](./toml.md) _(jaywcjlove.github.io)_
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wcj/reference",
|
||||
"version": "1.37.0",
|
||||
"version": "1.38.0",
|
||||
"description": "为开发人员分享快速参考备忘单(主要是方便自己)。",
|
||||
"author": "jaywcjlove",
|
||||
"license": "MIT",
|
||||
@ -30,7 +30,7 @@
|
||||
"husky": "^8.0.1",
|
||||
"lint-staged": "^13.0.3",
|
||||
"prettier": "^2.7.1",
|
||||
"refs-cli": "^1.3.2",
|
||||
"refs-cli": "^1.4.1",
|
||||
"markdownlint": "^0.27.0",
|
||||
"markdownlint-cli": "^0.33.0"
|
||||
},
|
||||
|
Reference in New Issue
Block a user