Skip to content

Commit e48ed22

Browse files
ducheng暮晨
ducheng
authored and
暮晨
committed
EX.Explicit typecast of strings
1 parent 2314259 commit e48ed22

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ So, here we go...
7878
- [Section: Miscellaneous](#section-miscellaneous)
7979
- [> `+=` is faster/更快的 `+=` ](#--is-faster更快的-)
8080
- [> Let's make a giant string!/来做个巨大的字符串吧!](#-lets-make-a-giant-string来做个巨大的字符串吧)
81-
- [> Explicit typecast of strings](#-explicit-typecast-of-strings)
81+
- [> Explicit typecast of strings/字符串的显式类型转换](#-explicit-typecast-of-strings字符串的显式类型转换)
8282
- [> Minor Ones](#-minor-ones)
8383
- [Contributing](#contributing)
8484
- [Acknowledgements](#acknowledgements)
@@ -2266,12 +2266,12 @@ def convert_list_to_string(l, iters):
22662266
22672267
---
22682268
2269-
### > Explicit typecast of strings
2269+
### > Explicit typecast of strings/字符串的显式类型转换
22702270
22712271
```py
22722272
a = float('inf')
22732273
b = float('nan')
2274-
c = float('-iNf') #These strings are case-insensitive
2274+
c = float('-iNf') # 这些字符串不区分大小写
22752275
d = float('nan')
22762276
```
22772277
@@ -2289,7 +2289,7 @@ ValueError: could not convert string to float: some_other_string
22892289
True
22902290
>>> None == None # None==None
22912291
True
2292-
>>> b == d #but nan!=nan
2292+
>>> b == d #但是 nan!=nan
22932293
False
22942294
>>> 50/a
22952295
0.0
@@ -2299,9 +2299,9 @@ nan
22992299
nan
23002300
```
23012301
2302-
#### 💡 Explanation:
2302+
#### 💡 说明:
23032303
2304-
`'inf'` and `'nan'` are special strings (case-insensitive), which when explicitly typecasted to `float` type, are used to represent mathematical "infinity" and "not a number" respectively.
2304+
`'inf'` `'nan'` 是特殊的字符串(不区分大小写), 当显示转换成 `float` 型时, 它们分别用于表示数学意义上的 "无穷大" 和 "非数字".
23052305
23062306
---
23072307

0 commit comments

Comments
 (0)