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__']
意为查询当前目录下的所有目录和文件。
第二题稍后
Sign in to make a reply
清水的sccd
输出为: