網站首頁 編程語言 正文
1、os.path
方法
# -*- coding: utf-8 -*- # !/usr/bin/python import os import sys current_directory = os.path.dirname(os.path.abspath(__file__)) print(current_directory)
輸出:
2、os.path.abspath
方法
# -*- coding: utf-8 -*- # !/usr/bin/python import os import sys root_path = os.path.abspath(os.path.dirname(current_directory) + os.path.sep + ".") sys.path.append(root_path) print(sys.path[0])
輸出:
3、os.getcwd
方法
currentPath = os.getcwd().replace('\\','/') # 獲取當前路徑 print(currentPath)
輸出:
原文鏈接:https://blog.csdn.net/hongzhen91/article/details/103274923
相關推薦
- 2023-01-31 React組件通信淺析_React
- 2024-03-05 layui彈出層的表單驗證(form表單自帶的驗證不執行)
- 2022-04-20 C#實現變量交換、斐波那契數列、質數、回文方法合集_C#教程
- 2022-10-27 Python數值求解微分方程方法(歐拉法,隱式歐拉)_python
- 2022-03-23 C語言利用system調用系統命令行詳情_C 語言
- 2022-10-31 Rust?實現?async/await的詳細代碼_相關技巧
- 2022-05-19 python中join與os.path.join()函數實例詳解_python
- 2022-11-17 python??Matplotlib繪圖直線,折線,曲線_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支