python3 获取当前路径及os.path.dirname的使用
方法一:
import os
os.getcwd() #直接获取结果
import os
开发环境
//RUNSTATUS = "dev"
测试环境
//RUNSTATUS = "test"
线上环境
//RUNSTATUS = "online" # 线上环境
SYSTEM_STATUS = True if "windows" in platform.platform().lower() else False # 操作系统
if SYSTEM_STATUS:
txt_file_name = os.getcwd() + 'data\app\spuid.txt'
else:
txt_file_name = os.getcwd() + 'data/app/spuid.txt'
print(txt_file_name)
with open(txt_file_name, 'r', encoding='utf8') as fr:
data = fr.read()
sp_list = data.split(',')
print("sp_list)
for id in sp_list:
print(id)
方法二:
import