标签:bsp get arm 创建 拼接 soft data int join
路径处理,需导入 os包
1 import os # 导入 os 包 2 3 """获取当前运行文件所在文件夹的路径01""" 4 current_dir = os.getcwd() # 无参数 5 print(current_dir) # 当前运行文件的上一级目录,输出:D:\soft\pycharm\Project_Script\基础 6 7 """绝对路径""" 8 print(os.path.abspath(__file__)) 9 print(os.path.realpath(__file__)) # 都输出:D:\soft\pycharm\Project_Script\基础\路径处理.py 10 11 """获取当前运行文件所在文件夹的路径02""" 12 path = os.path.abspath(__file__) 13 print(os.path.dirname(path)) # 输出:D:\soft\pycharm\Project_Script\基础
路径拼接 os.path.join(path, ‘data‘)
1 import os 2 3 # 获取当前文件的上一级目录 4 path_dir = os.path.dirname(os.path.abspath(__file__)) # path_dir = os.getcwd() 5 6 # 路径拼接 7 data_path = os.path.join(path_dir, ‘data‘) 8 print(data_path) # 输出:D:\soft\pycharm\Project_Script\基础\data
创建目录
标签:bsp get arm 创建 拼接 soft data int join
原文地址:https://www.cnblogs.com/qyyan/p/12892234.html