小编con*_*293的帖子

Python sorted()vs .sort()用于目录列表

file_list = os.listdir(os.getcwd)
files = file_list.sort()
Run Code Online (Sandbox Code Playgroud)

如果我有一个基于上面目录列表的列表,为什么有时候如果使用files.sort()函数返回NoneType但是使用sorted(files)函数返回目标排序?

python sorting directory

1
推荐指数
1
解决办法
2994
查看次数

同时迭代多个列表

是否可以迭代多个列表并从同一循环中的不同列表返回参数?

即,而不是 -

For x in trees:
  Print(x) 
For y in bushes:
  Print(y)
Run Code Online (Sandbox Code Playgroud)

就像是 -

For x,y in trees,bushes:
  Print(x +"\n"+ y)
Run Code Online (Sandbox Code Playgroud)

python loops for-loop list

0
推荐指数
1
解决办法
761
查看次数

标签 统计

python ×2

directory ×1

for-loop ×1

list ×1

loops ×1

sorting ×1