整数中1出现的次数(从1到n整数中1出现的次数) 2014/10/22 14628 # -*- 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