栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python test2

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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])
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/998292.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号