import os
os.chdir("C:\\Users\diodi\\OneDrive\\Desktop\\September2018")
for i in os.listdir("C:\\Users\diodi\\OneDrive\\Desktop\\September2018"):
if len(i)==16:
print(i)
for i in os.listdir("C:\\Users\diodi\\OneDrive\\Desktop\\September2018"):
if len(i) == 17:
print(i)
如果我在同一个for循环中使用了两个if循环,就会像这样1,10,11,12 ... 2,20,21..3,30,4,5,6
这是我想要的输出,是否有更好的方法按此顺序对它们进行排序?
1 september.pdf
2 september.pdf
3 september.pdf
4 september.pdf
5 september.pdf
6 september.pdf
7 september.pdf
8 september.pdf
9 september.pdf
10 september.pdf
11 september.pdf
12 september.pdf
13 september.pdf
14 september.pdf
15 september.pdf
16 september.pdf
17 september.pdf
18 september.pdf