整数中1出现的次数(从1到n整数中1出现的次数)

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

# -*- coding:utf-8 -*-
class Solution:
    def NumberOf1Between1AndN_Solution(self, n):
        count = 0
        for item in range(1,n+1):
            pstr = str(item)
            count += pstr.count('1')
        return count