Skip to content

Commit e041e84

Browse files
duchengleisurelicht
ducheng
authored andcommitted
EX.Explicit typecast of strings
1 parent c5dba5b commit e041e84

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

README.md

+6-6
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)
@@ -2272,12 +2272,12 @@ def convert_list_to_string(l, iters):
22722272
22732273
---
22742274
2275-
### > Explicit typecast of strings
2275+
### > Explicit typecast of strings/字符串的显式类型转换
22762276
22772277
```py
22782278
a = float('inf')
22792279
b = float('nan')
2280-
c = float('-iNf') #These strings are case-insensitive
2280+
c = float('-iNf') # 这些字符串不区分大小写
22812281
d = float('nan')
22822282
```
22832283
@@ -2295,7 +2295,7 @@ ValueError: could not convert string to float: some_other_string
22952295
True
22962296
>>> None == None # None==None
22972297
True
2298-
>>> b == d #but nan!=nan
2298+
>>> b == d #但是 nan!=nan
22992299
False
23002300
>>> 50/a
23012301
0.0
@@ -2305,9 +2305,9 @@ nan
23052305
nan
23062306
```
23072307
2308-
#### 💡 Explanation:
2308+
#### 💡 说明:
23092309
2310-
`'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.
2310+
`'inf'` `'nan'` 是特殊的字符串(不区分大小写), 当显示转换成 `float` 型时, 它们分别用于表示数学意义上的 "无穷大" 和 "非数字".
23112311
23122312
---
23132313

0 commit comments

Comments
 (0)