網站首頁 編程語言 正文
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
相關推薦
- 2022-07-15 Python中五種實現字符串反轉的方法_python
- 2022-08-12 關于VSCode?配置使用?PyLint?語法檢查器的問題_python
- 2022-06-28 C++哈希表之線性探測法實現詳解_C 語言
- 2023-10-30 springboot application 常用配置
- 2023-01-20 Python輸入整數進行排序方式_python
- 2022-05-17 C++設計模式狀態模式(State)
- 2023-12-14 Excel中——日期列后添加星期
- 2023-02-04 Go語言中websocket的使用demo分享_Golang
- 最近更新
-
- 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同步修改后的遠程分支