python test2

	
# -*- 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])

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值