os.path.split(os.path.split(os.path.realpath())window系统路径怎么写
时间: 2024-01-11 11:40:47 浏览: 74
Python常用模块os.path之文件及路径操作方法
在Windows系统中,使用os.path.split()函数可以将路径分解为目录名和文件名。要获取当前文件的目录名,可以使用以下代码:os.path.split(os.path.realpath(__file__))[0。其中,__file__表示当前文件的路径,os.path.realpath()函数返回该路径的绝对路径。最后,os.path.split()函数将绝对路径分解为目录名和文件名,并通过索引获取目录名。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [python3 获取当前路径及os.path.dirname sys.path.dirname的使用](https://blog.csdn.net/gqv2009/article/details/120513546)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [Python-路径处理:glob模块、os.path模块](https://blog.csdn.net/u011079613/article/details/122521579)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文