比方说,该程序将通过以下命令行运行:
python3 program.py下载
这是我到目前为止所拥有的。
import os
path = "Desktop" //how do I change path to the random user inputed directory provided by command line?
fname = []
for root,d_names,f_names in os.walk(path):
for f in f_names:
fname.append(os.path.join(root, f))
print("fname = %s" %fname)
输出:
fname = ['Desktop/Junk.odt']
我需要知道如何在给定目录中找到最大的文件并另外打印文件大小