Skip to content

Commit 4a2e8b4

Browse files
为扩展类型String添加了__len__()方法
1 parent bca2a58 commit 4a2e8b4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

type.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = "Jerry"
2-
__version__ = "1.2.2"
2+
__version__ = "1.2.3"
33

44
class NotComposedOfNumbersError(Exception):
55
"不是由数字组成的字符串使用String对象的toInt()函数或toInteger()函数时抛出"
@@ -20,6 +20,10 @@ def __repr__(self) -> str:
2020

2121
__str__ = __repr__
2222

23+
def __len__(self):
24+
"使用len()函数时调用"
25+
return self.length
26+
2327
def __add__(self, other):
2428
"当与一个字符串或另一个String对象进行加操作时调用"
2529
if type(other) is String:

0 commit comments

Comments
 (0)