File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed
i18n/zh-cn/docusaurus-plugin-content-docs/current Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -9,20 +9,20 @@ sidebar_label: 类型转换
99
1010### 任务
1111
12- 假设有一块硬盘的容量为 8192MB(字符串),请将这块硬盘的容量换算为 TB 单位,将换算结果保存到一个整数类型变量中。
12+ 假设有一块硬盘的容量为 8192MB(字符串),请将这块硬盘的容量换算为 GB 单位,将换算结果保存到一个整数类型变量中。
1313
1414#### JavaScript 实现
1515``` javascript
16- let gb = ' 8192MB' ;
17- let tb = parseInt (gb ) / 1024
18- let intTb = parseInt (tb )
19- console .log (` 该硬盘容量为: ${ intTb } TB ` )
16+ let mb = ' 8192MB' ;
17+ let gb = parseInt (mb ) / 1024
18+ let intGb = parseInt (gb )
19+ console .log (` 该硬盘容量为: ${ intGb } GB ` )
2020```
2121#### Python 实现
2222``` python
23- gb = ' 8192MB'
24- int_tb = int (gb [:- 2 ]) // 1024
25- print (f " 该硬盘容量为: { int_tb } TB " )
23+ mb = ' 8192MB'
24+ int_gb = int (mb [:- 2 ]) // 1024
25+ print (f " 该硬盘容量为: { int_gb } GB " )
2626```
2727
2828### 代码解读
@@ -44,5 +44,3 @@ print(f"该硬盘容量为: {int_tb}TB")
4444
4545### 相关资源
4646- https://docs.python.org/3/library/functions.html
47-
48-
You can’t perform that action at this time.
0 commit comments