str = 'a-bc-12----3'
num = []
for n in str:
if n == '-':
num += n
continue
print(num.count('-'))
#或者
str = 'a-bc-12----3'
i = 0
for n in str:
if n == '-':
i += 1
continue
print(i)
版权归原作者 sunny_eggg 所有, 如有侵权,请联系我们删除。