以下是我的代码:
str
我要模拟“ result.getStatus()”。我正在使用PowerMockito模拟ScanResult
def count_threes(x):
count = 0
for item in x:
if isinstance(item, str) or isinstance(item, bytes):
continue # skip to avoid infinite recursion
if hasattr(item, '__iter__'): # is an iterable
count += count_threes(item)
elif item == 3:
count += 1
return count
count_threes(x)
20
有人知道答案吗,请提前感谢您的帮助。