1 import os 2 3 print ‘***获取当前目录***‘ 4 print os.getcwd() 5 print os.path.abspath(os.path.dirname(__file__)) 6 7 print ‘***获取上级目录***‘ 8 print os.path.abspath(os.path.dirname(os.path.dirname(__file__))) 9 print os.path.abspath(os.path.dirname(os.getcwd())) 10 print os.path.abspath(os.path.join(os.getcwd(), "..")) 11 12 print ‘***获取上上级目录***‘ 13 print os.path.abspath(os.path.join(os.getcwd(), "../.."))
原文地址:https://www.cnblogs.com/dingchuan/p/9381769.html
时间: 2024-12-15 19:02:19