#coding=UTF-8
import os
# 当前路径
current_path = os.path.dirname(__file__)
# 上一级路径(父级路径)
parent_path = os.path.dirname(current_path)
print("当前路径:" + current_path)
print("上一级路径:" + parent_path)
Python获取当前目录路径和上一级目录路径(父级路径)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
Python3 012:100到200的素数
依汉南
2020-07-08 05:45:09
Python3 个税计算
依汉南
2020-07-08 05:45:09
Python3 阶乘求和
依汉南
2020-07-08 05:45:09
Python3 磁盘读写
依汉南
2020-07-08 05:45:09
Python3 完全平方数
依汉南
2020-07-08 05:45:09
Python3 这天第几天
依汉南
2020-07-08 05:45:09
Python3 copy
依汉南
2020-07-08 05:45:09
Python3 数字组合
依汉南
2020-07-08 05:45:09
关于 Jupyter notebook 的 kernel error 问题
汤姆鱼
2020-07-07 23:19:57
Anaconda 和 PyCharm 的安装与配置
汤姆鱼
2020-07-07 23:19:57
Python3 学习笔记之基础语法
汤姆鱼
2020-07-07 23:19:57
python生成pyc
jiguoguo
2020-07-07 22:43:30
开启CSDN笔记模式
時間荏苒,今天以前同事請我下載CSDN資源,無意登錄賬號,已經碼農13年。 把我所有筆記陸續更新到CSDN,重拾10餘年前的習慣。
jiguoguo
2020-07-07 22:43:30
centos安装思源黑体
jiguoguo
2020-07-07 22:43:30