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: 类型转换
9
9
10
10
### 任务
11
11
12
- 假设有一块硬盘的容量为 8192MB(字符串),请将这块硬盘的容量换算为 TB 单位,将换算结果保存到一个整数类型变量中。
12
+ 假设有一块硬盘的容量为 8192MB(字符串),请将这块硬盘的容量换算为 GB 单位,将换算结果保存到一个整数类型变量中。
13
13
14
14
#### JavaScript 实现
15
15
``` 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 ` )
20
20
```
21
21
#### Python 实现
22
22
``` 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 " )
26
26
```
27
27
28
28
### 代码解读
@@ -44,5 +44,3 @@ print(f"该硬盘容量为: {int_tb}TB")
44
44
45
45
### 相关资源
46
46
- https://docs.python.org/3/library/functions.html
47
-
48
-
You can’t perform that action at this time.
0 commit comments