import os
os.path.basename(os.path.dirname(os.path.realpath(__file__)))
分解:
currentFile = __file__ # May be 'my_script', or './my_script' or
# '/home/user/test/my_script.py' depending on exactly how
# the script was run/loaded.
realPath = os.path.realpath(currentFile) # /home/user/test/my_script.py
dirPath = os.path.dirname(realPath) # /home/user/test
dirName = os.path.basename(dirPath) # test
就写吧
希望这有帮助。。。
分解:
相关问题 更多 >
编程相关推荐