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

 

#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
posted @ 2021-11-09 16:25  你是我的小妖精  阅读(34)  评论(0)    收藏  举报