azev
V2EX  ›  问与答

问个 Python 的列表生成式 循环目录列表 返回每个目录及目录下第一个文件

  •  
  •   azev · Nov 30, 2022 · 894 views
    This topic created in 1343 days ago, the information mentioned may be changed or developed.

    能不能搞成?

    azev
        1
    azev  
    OP
       Nov 30, 2022
    原来不麻烦 return [(dir,os.listdir(dir)[0]) for dir in dirList ]
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5298 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 08:33 · PVG 16:33 · LAX 01:33 · JFK 04:33
    ♥ Do have faith in what you're doing.