2
2
对Python原版类型的扩展
3
3
"""
4
4
__author__ = "Jerry"
5
- __version__ = "1.3.7 "
5
+ __version__ = "1.3.8 "
6
6
7
7
__all__ = ["String" , "Integer" , "List" ]
8
8
@@ -269,7 +269,19 @@ def __init__(self, list_) -> None:
269
269
self .length = len (list_ ) # 列表长度
270
270
271
271
def __repr__ (self ) -> str :
272
- return "[%s]" % (", " .join (self .__list ))
272
+ r = []
273
+ for i in self .__list :
274
+ if type (i ) is str :
275
+ r .append ("'%s'" % i )
276
+ elif type (i ) is int :
277
+ r .append (str (i ))
278
+ elif type (i ) is String :
279
+ r .append ("<Extension Type String '%s'>" % i .getNormal ())
280
+ elif type (i ) is Integer :
281
+ r .append ("<Extension Type Integer %s>" % i .toStr ())
282
+ elif type (i ) is List :
283
+ r .append ("<Extension Type List %s>" % i .getNormal ())
284
+ return "[%s]" % (", " .join (r ))
273
285
274
286
__str__ = __repr__
275
287
@@ -341,7 +353,7 @@ def toStrList(self):
341
353
"如果列表包含整数,返回一个将整数转为字符串的列表"
342
354
strList = []
343
355
for i in self .__list :
344
- if i is int :
356
+ if type ( i ) is int :
345
357
strList .append (str (i ))
346
358
else :
347
359
strList .append (i )
@@ -351,8 +363,9 @@ def toIntList(self):
351
363
"如果列表包含字符串,返回一个将字符串转为整数的列表"
352
364
intList = []
353
365
for i in self .__list :
354
- if i .isdigit ():
355
- intList .append (int (i ))
366
+ if type (i ) is str :
367
+ if i .isdigit ():
368
+ intList .append (int (i ))
356
369
else :
357
370
intList .append (i )
358
371
return intList
@@ -361,7 +374,7 @@ def toStringList(self):
361
374
"如果列表包含字符串,返回一个将字符串转为String对象的列表"
362
375
stringList = []
363
376
for i in self .__list :
364
- if i is str :
377
+ if type ( i ) is str :
365
378
stringList .append (String (i ))
366
379
else :
367
380
stringList .append (i )
@@ -371,7 +384,7 @@ def toIntegerList(self):
371
384
"如果列表包含整数,返回一个将整数转为Integer对象的列表"
372
385
integerList = []
373
386
for i in self .__list :
374
- if i is int :
387
+ if type ( i ) is int :
375
388
integerList .append (Integer (i ))
376
389
else :
377
390
integerList .append (i )
0 commit comments