# -*- coding: utf-8 -*-
# import os
# # file_path='D:\\study\\study'
# lis=[]
# new_path=[]
ch_list=['ch=0','ch=1']
ce_list=['ce=0','ce=1']
lun_list=['lun=0','lun=1']
# def get_file(path):
# FileName=os.listdir(path)
# print(FileName)
# for filename in FileName:
# cur_path=os.path.join(path,filename)
# if os.path.isdir(cur_path):
# get_file(cur_path)
# else:
# lis.append(cur_path)
# return lis
# path='D:\\xieru\\'
# file_list=get_file(path)
# print(file_list)
data_mock=[
['ch=1',"ce=0","lun=1","TU1"],
['ch=0',"ce=0","lun=1","TU1"],
['ch=1',"ce=0","lun=1","TU2"],
['ch=1',"ce=1","lun=1","TU1"],
['ch=1',"ce=0","lun=0","TU2"],
['ch=1',"ce=0","lun=1","TU1"],
['ch=1',"ce=0","lun=1","TU1"],
['ch=1',"ce=0","lun=1","TU9"],
['ch=1',"ce=0","lun=1","TU1"],
['ch=0',"ce=0","lun=1","TU3"],
['ch=1',"ce=0","lun=1","TU8"],
['ch=1',"ce=0","lun=1","TU1"],
['ch=1',"ce=0","lun=1","TU5"],
['ch=1',"ce=0","lun=1","TU5"],
]
def reder(data):
for item in data:
forEach(item)
list1=[] # ch=0 ch=0 lun=0
list2=[] #001
list3=[] #001
list4=[] #001
list5=[] #001
list6=[] #001
list7=[] #001
list8=[] #001
#过滤数据 把ch ce lun并且 row【6】不等于空的过滤出来
def forEach(row):
for ch in ch_list: #ch=0 ch=1
for ce in ce_list: #ce=0 ce=1
for lun in lun_list: #lun=0 lun=1
if row[0]==ch and row[1]==ce and row[2]==lun:
push(row)
#分类 添加
def push(row):
if row[0]=='ch=0' and row[1]=='ce=0' and row[2]=='lun=0':
list1.append(row)
elif row[0]=='ch=0' and row[1]=='ce=0' and row[2]=='lun=1':
list2.append(row)
elif row[0]=='ch=0' and row[1]=='ce=1' and row[2]=='lun=0':
list3.append(row)
elif row[0]=='ch=0' and row[1]=='ce=1' and row[2]=='lun=1':
list4.append(row)
elif row[0]=='ch=1' and row[1]=='ce=0' and row[2]=='lun=0':
list5.append(row)
elif row[0]=='ch=1' and row[1]=='ce=0' and row[2]=='lun=1':
list6.append(row)
elif row[0]=='ch=1' and row[1]=='ce=1' and row[2]=='lun=0':
list7.append(row)
elif row[0]=='ch=1' and row[2]=='ce=1' and row[3]=='lun=1':
list8.append(row)
if __name__=="__main__":
reder(data_mock)
#获取list
price_result=[] #存放概率结果
#概率写入计算
res=[]
price1=len(list1)/2200
res.append(["ch=0","ce=0","lun=0",price1])
python test2
最新推荐文章于 2023-11-13 13:36:04 发布