思路是参考的另一个博客的,不过他是java代码写的.
for i in range(111,334):
if str(i).count('0')==1:
continue
b=i*2
if str(b).count('0')==1:
continue
c = i * 3
if str(c).count('0')==1:
continue
c=(str(i) + str(b) + str(c))
c=list(map(int,c))
d=sorted(c)
e=[1,2,3,4,5,6,7,8,9]
if e==d:
print(i)
其中想对字符串排序,因为字符串没有排序功能,所以需要先转换成列表,然后再排序。
注意,如果直接使用d=c.sort(),会出现d为None的情况。
运行结果:
参考链接:
字符串排列升序降序:https://www.nhooo.com/note/qa0d4e.html



