File tree 1 file changed +18
-2
lines changed
1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 2
2
对Python原版类型的扩展
3
3
"""
4
4
__author__ = "Jerry"
5
- __version__ = "1.3.6 "
5
+ __version__ = "1.3.7 "
6
6
7
7
__all__ = ["String" , "Integer" , "List" ]
8
8
@@ -85,6 +85,10 @@ def __ge__(self, other) -> bool:
85
85
else :
86
86
return self .__str >= other
87
87
88
+ def getNormal (self ):
89
+ "将扩展类型转为原版类型"
90
+ return self .__str
91
+
88
92
def isNumber (self ):
89
93
"判断字符串是否由数字组成,返回布尔值"
90
94
try :
@@ -217,6 +221,10 @@ def __ge__(self, other) -> bool:
217
221
else :
218
222
return self .__int >= other
219
223
224
+ def getNormal (self ):
225
+ "将扩展类型转为原版类型"
226
+ return self .__int
227
+
220
228
def isEven (self ):
221
229
"判断数字是否是偶数,返回布尔值"
222
230
if self .__int % 2 == 0 :
@@ -258,13 +266,17 @@ def __init__(self, list_) -> None:
258
266
"请使用列表类型创建List对象"
259
267
)
260
268
self .__list = list_
261
- self .length = len (list_ )
269
+ self .length = len (list_ ) # 列表长度
262
270
263
271
def __repr__ (self ) -> str :
264
272
return "[%s]" % (", " .join (self .__list ))
265
273
266
274
__str__ = __repr__
267
275
276
+ def __len__ (self ):
277
+ "使用len()函数时调用"
278
+ return self .length
279
+
268
280
def __add__ (self , other ):
269
281
"当与一个整数或另一个List对象进行加操作时调用"
270
282
if type (other ) is List :
@@ -321,6 +333,10 @@ def __ge__(self, other) -> bool:
321
333
else :
322
334
return self .__list >= other
323
335
336
+ def getNormal (self ):
337
+ "将扩展类型转为原版类型"
338
+ return self .__list
339
+
324
340
def toStrList (self ):
325
341
"如果列表包含整数,返回一个将整数转为字符串的列表"
326
342
strList = []
You can’t perform that action at this time.
0 commit comments