30 lines
887 B
Python
30 lines
887 B
Python
![]() |
import os
|
|||
|
from library.functions import get_path
|
|||
|
|
|||
|
|
|||
|
class DirManager():
|
|||
|
def __init__(self):
|
|||
|
self.base_dir = get_path()
|
|||
|
self.log_dir = self.base_dir + '//log'
|
|||
|
|
|||
|
self.create_directory(self.log_dir)
|
|||
|
print(self.log_dir)
|
|||
|
|
|||
|
|
|||
|
# 查看是否存在保存光谱和影像文件的目录,如果没有就创建
|
|||
|
def create_directory(self, directory):
|
|||
|
'''
|
|||
|
:param directory: 需要创建的文件夹绝对路径,不能将参数directory省略而在此函数内部使用self.log_dir,
|
|||
|
因为本类的继承类也需要使用此函数
|
|||
|
:return:
|
|||
|
'''
|
|||
|
if not os.path.exists(directory):
|
|||
|
print('创建文件夹:', directory)
|
|||
|
os.makedirs(directory)
|
|||
|
# else:
|
|||
|
# print('文件夹存在:%s' % self.log_dir)
|
|||
|
|
|||
|
|
|||
|
if __name__ == '__main__':
|
|||
|
x = DirManager()
|