Print Current Working Directory

博客提及了pwd,pwd是命令行中用于显示当前工作目录的命令,属于信息技术领域基础操作内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

pwd
def search_astra_datalog( directory: str = os.getcwd(), filelist: list = [], depth: int = 0, max_depth: int = 10, ) -> list: """ Traverse the files and folders from the current working directory downwards to find and collect astra data log. Parameters ---------- directory : str, default current working directory Used to specify the absolute starting directory path. By default, it starts from the directory path where the script is run, and you can also customize the directory path. filelist : list, default [] The directory path used to store the astra data log from the collected. The default is an empty list, or you can use a defined list. depth : int, default 0 Used to specify the starting directory level. If you know the exact starting directory level, you can define it here to reduce operating time. max_depth : int, default 10 Used to specify the ending directory level. You can specify the deepest directory level so that you can end the traversal early. Returns ------- list The returns contains the absolute directory path of all astra data logs. Notes ----- ...... """ new_directory = directory if os.path.isfile(directory): if ( "csv" in directory and not "event" in directory and not "tar.gz" in directory and "#" in directory ): filelist.append(directory) elif os.path.isdir(directory): if depth < max_depth: try: for s in os.listdir(directory): new_directory = os.path.join(directory, s) search_astra_datalog(new_directory, filelist, depth + 1, max_depth) except PermissionError: print(f"Access denied to directoryectory: {directory}") return filelist其中在前一循环输出的new_directory会被第二次循环中的new_directory=directory这一步赋值覆盖么?
08-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值