【为给定字符串提出数字】看到群里面试分享一个面试题 结果给定回复是不严谨的故记录一下

 

#coding:utf8
#author:mylittlegoblin

class Test_Getint:
def get_int(self,words):
return int(''.join(filter(str.isdigit,words)))
def test_get_int(self):
assert self.get_int("1b3b4n") == 134
assert self.get_int("11b22b44b") == 112244
样写的不严谨 修改后的如下:
#coding:utf8
#author:mylittlegoblin

class Test_Getint:
def get_int(self,words:str) -> int:
return int(''.join(filter(str.isdigit,words)))
def test_get_int(self):
assert self.get_int("1b3b4n") == 134
assert self.get_int("11b22b44b") == 112244
上一篇:c++代码调试,宏调试,assert报错弹框


下一篇:utf8字符串处理 utf8Ext