update
@@ -45,6 +45,10 @@ export default defineConfig({
|
|||||||
link: "/basic/tips/error-message/index.md",
|
link: "/basic/tips/error-message/index.md",
|
||||||
},
|
},
|
||||||
{ text: "使用 AI", link: "/basic/tips/chatgpt/index.md" },
|
{ text: "使用 AI", link: "/basic/tips/chatgpt/index.md" },
|
||||||
|
{
|
||||||
|
text: "可视化执行流程",
|
||||||
|
link: "/basic/tips/pythontutor/index.md",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,24 +3,44 @@
|
|||||||
> 抄抄抄
|
> 抄抄抄
|
||||||
|
|
||||||
1. 输出保留两位小数
|
1. 输出保留两位小数
|
||||||
|
|
||||||
```py
|
```py
|
||||||
a = 10.2980
|
a = 10.2980
|
||||||
print("%.2f" % a)
|
print("%.2f" % a)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
2. 输入一个整数
|
2. 输入一个整数
|
||||||
|
|
||||||
|
比如输入128
|
||||||
|
|
||||||
```py
|
```py
|
||||||
a=int(input())
|
a=int(input())
|
||||||
```
|
```
|
||||||
|
|
||||||
|
得到变量a就是整数128
|
||||||
|
|
||||||
3. 输入两个整数,用空格隔开
|
3. 输入两个整数,用空格隔开
|
||||||
|
|
||||||
|
比如输入 10 20
|
||||||
|
|
||||||
```py
|
```py
|
||||||
n=input().split()
|
n=input().split()
|
||||||
a=int(n[0])
|
a=int(n[0])
|
||||||
b=int(n[1])
|
b=int(n[1])
|
||||||
```
|
```
|
||||||
|
|
||||||
4. 输入文字,用空格隔开(这里用三个文字做例子,比如:iPhone Huawei Xiaomi)
|
得到变量a就是整数10,变量b就是整数20
|
||||||
|
|
||||||
|
4. 输入文字,用空格隔开
|
||||||
|
|
||||||
|
比如输入 iPhone Huawei Xiaomi
|
||||||
|
|
||||||
```py
|
```py
|
||||||
a,b,c=input().split()
|
n=input().split()
|
||||||
|
a=n[0]
|
||||||
|
b=n[1]
|
||||||
|
c=n[2]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
得到变量a就是iPhone,变量b就是Huawei,变量c就是Xiaomi
|
||||||
|
|||||||
BIN
basic/tips/pythontutor/PixPin_2024-12-19_11-19-48.gif
Normal file
|
After Width: | Height: | Size: 260 KiB |
BIN
basic/tips/pythontutor/PixPin_2024-12-19_11-22-54.gif
Normal file
|
After Width: | Height: | Size: 154 KiB |
BIN
basic/tips/pythontutor/PixPin_2024-12-19_11-26-35.gif
Normal file
|
After Width: | Height: | Size: 496 KiB |
BIN
basic/tips/pythontutor/image-1.png
Normal file
|
After Width: | Height: | Size: 93 KiB |
BIN
basic/tips/pythontutor/image-10.png
Normal file
|
After Width: | Height: | Size: 166 KiB |
BIN
basic/tips/pythontutor/image-2.png
Normal file
|
After Width: | Height: | Size: 112 KiB |
BIN
basic/tips/pythontutor/image-3.png
Normal file
|
After Width: | Height: | Size: 92 KiB |
BIN
basic/tips/pythontutor/image-4.png
Normal file
|
After Width: | Height: | Size: 190 KiB |
BIN
basic/tips/pythontutor/image-5.png
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
basic/tips/pythontutor/image-6.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
basic/tips/pythontutor/image-7.png
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
basic/tips/pythontutor/image-8.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
basic/tips/pythontutor/image-9.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
basic/tips/pythontutor/image.png
Normal file
|
After Width: | Height: | Size: 188 KiB |
81
basic/tips/pythontutor/index.md
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
# 使用 [pythontutor.com](https://pythontutor.com/) 可视化的执行流程
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
由于网站都是英文的,所以接下来我会一步步的截图,请按照顺序执行
|
||||||
|
|
||||||
|
## 1. 选择编程语言
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 2. 在输入框中粘贴代码
|
||||||
|
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
```py
|
||||||
|
n=1
|
||||||
|
i=0
|
||||||
|
while i<5:
|
||||||
|
i=i+1
|
||||||
|
n=n*2
|
||||||
|
print(n)
|
||||||
|
```
|
||||||
|
|
||||||
|
## 3. 点击【可视化执行】按钮
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 4. 进入调试页面
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
① 绿色箭头表示【当前正在】执行的语句
|
||||||
|
|
||||||
|
② 红色箭头表示【接下来要】执行的语句
|
||||||
|
|
||||||
|
③ 输出结果
|
||||||
|
|
||||||
|
④ 显示变量的值
|
||||||
|
|
||||||
|
## 5. 基础调试
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
5.1 不断点击 ①【Next 下一步】按钮
|
||||||
|
|
||||||
|
5.2 代码左侧 ② 出现绿色和红色箭头,指向【当前】和【接下来】的执行语句。
|
||||||
|
|
||||||
|
5.3 右侧 ③ 实时展示变量的值
|
||||||
|
|
||||||
|
**注意观察箭头的走向和变量值的变化**
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 6. 拖动进度条 *
|
||||||
|
|
||||||
|
可以拖动进度条反复查看,或者点击【First】跳到第一步,【Last】直接跳到最后一步
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 7. 更改代码再次调试
|
||||||
|
|
||||||
|
点击【Edit this code】按钮可以修改代码
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
**可以更改 i 的初始值 i=?,条件符号,条件值,计数器 i=i+? 等**
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
比如:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
遇到弹框,直接点按钮
|
||||||
|
|
||||||
|

|
||||||
72
package-lock.json
generated
@@ -11,12 +11,12 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@codemirror/lang-cpp": "^6.0.2",
|
"@codemirror/lang-cpp": "^6.0.2",
|
||||||
"@codemirror/lang-python": "^6.1.6",
|
"@codemirror/lang-python": "^6.1.6",
|
||||||
"axios": "^1.7.7",
|
"axios": "^1.7.9",
|
||||||
"codemirror": "^6.0.1",
|
"codemirror": "^6.0.1",
|
||||||
"vue-codemirror6": "~1.3.4"
|
"vue-codemirror6": "~1.3.8"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.4.2",
|
||||||
"vitepress": "1.5.0"
|
"vitepress": "1.5.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -472,13 +472,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@codemirror/lint": {
|
"node_modules/@codemirror/lint": {
|
||||||
"version": "6.8.2",
|
"version": "6.8.4",
|
||||||
"resolved": "https://registry.npmmirror.com/@codemirror/lint/-/lint-6.8.2.tgz",
|
"resolved": "https://registry.npmmirror.com/@codemirror/lint/-/lint-6.8.4.tgz",
|
||||||
"integrity": "sha512-PDFG5DjHxSEjOXk9TQYYVjZDqlZTFaDBfhQixHnQOEVDDNHUbEh/hstAjcQJaA6FQdZTD1hquXTK0rVBLADR1g==",
|
"integrity": "sha512-u4q7PnZlJUojeRe8FJa/njJcMctISGgPQ4PnWsd9268R4ZTtU+tfFYmwkBvgcrK2+QQ8tYFVALVb5fVJykKc5A==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@codemirror/state": "^6.0.0",
|
"@codemirror/state": "^6.0.0",
|
||||||
"@codemirror/view": "^6.0.0",
|
"@codemirror/view": "^6.35.0",
|
||||||
"crelt": "^1.0.5"
|
"crelt": "^1.0.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -493,18 +493,21 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@codemirror/state": {
|
"node_modules/@codemirror/state": {
|
||||||
"version": "6.4.1",
|
"version": "6.5.0",
|
||||||
"resolved": "https://registry.npmmirror.com/@codemirror/state/-/state-6.4.1.tgz",
|
"resolved": "https://registry.npmmirror.com/@codemirror/state/-/state-6.5.0.tgz",
|
||||||
"integrity": "sha512-QkEyUiLhsJoZkbumGZlswmAhA7CBU02Wrz7zvH4SrcifbsqwlXShVXg65f3v/ts57W3dqyamEriMhij1Z3Zz4A==",
|
"integrity": "sha512-MwBHVK60IiIHDcoMet78lxt6iw5gJOGSbNbOIVBHWVXIH4/Nq1+GQgLLGgI1KlnN86WDXsPudVaqYHKBIx7Eyw==",
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/@codemirror/view": {
|
|
||||||
"version": "6.34.2",
|
|
||||||
"resolved": "https://registry.npmmirror.com/@codemirror/view/-/view-6.34.2.tgz",
|
|
||||||
"integrity": "sha512-d6n0WFvL970A9Z+l9N2dO+Hk9ev4hDYQzIx+B9tCyBP0W5wPEszi1rhuyFesNSkLZzXbQE5FPH7F/z/TMJfoPA==",
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@codemirror/state": "^6.4.0",
|
"@marijn/find-cluster-break": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@codemirror/view": {
|
||||||
|
"version": "6.36.0",
|
||||||
|
"resolved": "https://registry.npmmirror.com/@codemirror/view/-/view-6.36.0.tgz",
|
||||||
|
"integrity": "sha512-aMePDnkNNKE8dSOo1w689xYa3dijREbRajiRcgjSGc2TWN7MTdE+9pm5fxwdz0C4D9Di1VZomrn2M+xDe7tTVg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@codemirror/state": "^6.5.0",
|
||||||
"style-mod": "^4.1.0",
|
"style-mod": "^4.1.0",
|
||||||
"w3c-keyname": "^2.2.4"
|
"w3c-keyname": "^2.2.4"
|
||||||
}
|
}
|
||||||
@@ -1013,6 +1016,12 @@
|
|||||||
"@lezer/lr": "^1.0.0"
|
"@lezer/lr": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@marijn/find-cluster-break": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmmirror.com/@marijn/find-cluster-break/-/find-cluster-break-1.0.2.tgz",
|
||||||
|
"integrity": "sha512-l0h88YhZFyKdXIFNfSWpyjStDjGHwZ/U7iobcK1cQQD8sejsONdQtTVU+1wVN1PBw40PiiHB1vA5S7VTfQiP9g==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@rollup/rollup-android-arm-eabi": {
|
"node_modules/@rollup/rollup-android-arm-eabi": {
|
||||||
"version": "4.24.0",
|
"version": "4.24.0",
|
||||||
"resolved": "https://registry.npmmirror.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.24.0.tgz",
|
"resolved": "https://registry.npmmirror.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.24.0.tgz",
|
||||||
@@ -1705,9 +1714,9 @@
|
|||||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||||
},
|
},
|
||||||
"node_modules/axios": {
|
"node_modules/axios": {
|
||||||
"version": "1.7.7",
|
"version": "1.7.9",
|
||||||
"resolved": "https://registry.npmmirror.com/axios/-/axios-1.7.7.tgz",
|
"resolved": "https://registry.npmmirror.com/axios/-/axios-1.7.9.tgz",
|
||||||
"integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==",
|
"integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"follow-redirects": "^1.15.6",
|
"follow-redirects": "^1.15.6",
|
||||||
@@ -2277,9 +2286,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/prettier": {
|
"node_modules/prettier": {
|
||||||
"version": "3.3.3",
|
"version": "3.4.2",
|
||||||
"resolved": "https://registry.npmmirror.com/prettier/-/prettier-3.3.3.tgz",
|
"resolved": "https://registry.npmmirror.com/prettier/-/prettier-3.4.2.tgz",
|
||||||
"integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==",
|
"integrity": "sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -2699,32 +2708,27 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/vue-codemirror6": {
|
"node_modules/vue-codemirror6": {
|
||||||
"version": "1.3.7",
|
"version": "1.3.8",
|
||||||
"resolved": "https://registry.npmmirror.com/vue-codemirror6/-/vue-codemirror6-1.3.7.tgz",
|
"resolved": "https://registry.npmmirror.com/vue-codemirror6/-/vue-codemirror6-1.3.8.tgz",
|
||||||
"integrity": "sha512-DG2LA5Ps2K8Ot1jlDeaRy28AhI9TKtcbRasT3WMooLxaWfHQcSKtbeANFqRSdECQjXiDVVYNTUte4Y7mR4XtEg==",
|
"integrity": "sha512-pCOzKzBBSFKi/SjUg+XGranV1vt+8S22z56BES/OeZtmyuj2M0CE0aczYS8qbTWNnKcuJcI5FRDHzVXy2v2Htg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@codemirror/commands": "^6.7.1",
|
"@codemirror/commands": "^6.7.1",
|
||||||
"@codemirror/language": "^6.10.3",
|
"@codemirror/language": "^6.10.3",
|
||||||
"@codemirror/lint": "^6.8.2",
|
"@codemirror/lint": "^6.8.3",
|
||||||
"@codemirror/state": "^6.4.1",
|
"@codemirror/state": "^6.4.1",
|
||||||
"@codemirror/view": "^6.34.2",
|
"@codemirror/view": "^6.35.0",
|
||||||
"codemirror": "^6.0.1",
|
"codemirror": "^6.0.1",
|
||||||
"style-mod": "^4.1.2",
|
"style-mod": "^4.1.2",
|
||||||
"vue-codemirror6": "file:",
|
|
||||||
"vue-demi": "latest"
|
"vue-demi": "latest"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"pnpm": ">=9.12.3"
|
"pnpm": ">=9.14.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"vue": "^2.7.14 || ^3.4"
|
"vue": "^2.7.14 || ^3.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/vue-codemirror6/node_modules/vue-codemirror6": {
|
|
||||||
"resolved": "node_modules/vue-codemirror6",
|
|
||||||
"link": true
|
|
||||||
},
|
|
||||||
"node_modules/vue-demi": {
|
"node_modules/vue-demi": {
|
||||||
"version": "0.14.10",
|
"version": "0.14.10",
|
||||||
"resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.14.10.tgz",
|
"resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.14.10.tgz",
|
||||||
|
|||||||
@@ -12,14 +12,14 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.4.2",
|
||||||
"vitepress": "1.5.0"
|
"vitepress": "1.5.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@codemirror/lang-cpp": "^6.0.2",
|
"@codemirror/lang-cpp": "^6.0.2",
|
||||||
"@codemirror/lang-python": "^6.1.6",
|
"@codemirror/lang-python": "^6.1.6",
|
||||||
"axios": "^1.7.7",
|
"axios": "^1.7.9",
|
||||||
"codemirror": "^6.0.1",
|
"codemirror": "^6.0.1",
|
||||||
"vue-codemirror6": "~1.3.4"
|
"vue-codemirror6": "~1.3.8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||