Discuss / Python / 第一个题解答

第一个题解答

Topic source

清水的sccd

#1 Created at ... [Delete] [Delete and Lock User]
import os
l = [x for x in os.listdir('.') if os.path.isfile(x) or os.path.isdir(x)]
print(l)

输出为:

['.idea', 'hello.py', 'io_test.py', 'mydict_test.py', 'new_hello.py', 'test.jpg', 'test.txt', '__pycache__']

清水的sccd

#2 Created at ... [Delete] [Delete and Lock User]

意为查询当前目录下的所有目录和文件。

第二题稍后


  • 1

Reply