File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 22对Python原版类型的扩展
33"""
44__author__ = "Jerry"
5- __version__ = "1.3.6 "
5+ __version__ = "1.3.7 "
66
77__all__ = ["String" , "Integer" , "List" ]
88
@@ -85,6 +85,10 @@ def __ge__(self, other) -> bool:
8585 else :
8686 return self .__str >= other
8787
88+ def getNormal (self ):
89+ "将扩展类型转为原版类型"
90+ return self .__str
91+
8892 def isNumber (self ):
8993 "判断字符串是否由数字组成,返回布尔值"
9094 try :
@@ -217,6 +221,10 @@ def __ge__(self, other) -> bool:
217221 else :
218222 return self .__int >= other
219223
224+ def getNormal (self ):
225+ "将扩展类型转为原版类型"
226+ return self .__int
227+
220228 def isEven (self ):
221229 "判断数字是否是偶数,返回布尔值"
222230 if self .__int % 2 == 0 :
@@ -258,13 +266,17 @@ def __init__(self, list_) -> None:
258266 "请使用列表类型创建List对象"
259267 )
260268 self .__list = list_
261- self .length = len (list_ )
269+ self .length = len (list_ ) # 列表长度
262270
263271 def __repr__ (self ) -> str :
264272 return "[%s]" % (", " .join (self .__list ))
265273
266274 __str__ = __repr__
267275
276+ def __len__ (self ):
277+ "使用len()函数时调用"
278+ return self .length
279+
268280 def __add__ (self , other ):
269281 "当与一个整数或另一个List对象进行加操作时调用"
270282 if type (other ) is List :
@@ -321,6 +333,10 @@ def __ge__(self, other) -> bool:
321333 else :
322334 return self .__list >= other
323335
336+ def getNormal (self ):
337+ "将扩展类型转为原版类型"
338+ return self .__list
339+
324340 def toStrList (self ):
325341 "如果列表包含整数,返回一个将整数转为字符串的列表"
326342 strList = []
You can’t perform that action at this time.
0 commit comments