daxiao jiou

import xlrd

#打开excel文件

#返回表的名字

# names = data.sheet_names()

# print (names)

# nrows = table.nrows  #获取该sheet中的有效行数

# print (nrows)

# jieguo = table.cell_value(1,2)  #返回单元格中的数据

# print(jieguo)

#处理列表,大小

def doLieBiao(shuju):

    doStr= []

for iin range(0,10):

        if(int(shuju[i])< 6):

            bijiao= 'x'

            doStr.append(bijiao)

else:

            bijiao= 'd'

            doStr.append(bijiao)

#print(doStr)

    return doStr

#处理列表奇数偶数

def doJiOu(shuju):

    doStr= []

for iin range(0,10):

        if(int(shuju[i])% 2 != 0):

            bijiao= 'j'

            doStr.append(bijiao)

else:

            bijiao= 'o'

            doStr.append(bijiao)

#print(doStr)

    return doStr

#获得所有结果的数组函数

def getAll():

    filename= "E://XYFT.xls"

    data= xlrd.open_workbook(filename)

table= data.sheets()[0]

bigStr= []

jiOuStr= []

for iin range(21,201):

        huoqu= table.cell_value(i,2)

#print(huoqu)

        huoqu1= huoqu.split(',')

#print(huoqu1)

        bigStr.append(doLieBiao(huoqu1))

jiOuStr.append(doJiOu(huoqu1))

return bigStr,jiOuStr

#处理大小并合并成字符串

def doHeBing(bigStr):

    oneStr=''

    twoStr=''

    threeStr= ''

    fourStr= ''

    fiveStr= ''

    sixStr= ''

    sevenStr= ''

    eightStr= ''

    nineStr= ''

    tenStr= ''

    for kin range(0,180):

        #rint (bigStr[k][j])

        oneStr= oneStr+ bigStr[k][0]

twoStr= twoStr+ bigStr[k][1]

threeStr= threeStr+ bigStr[k][2]

fourStr= fourStr+ bigStr[k][3]

fiveStr= fiveStr+ bigStr[k][4]

sixStr= sixStr+ bigStr[k][5]

sevenStr= sevenStr+ bigStr[k][6]

eightStr= eightStr+ bigStr[k][7]

nineStr= nineStr+ bigStr[k][8]

tenStr= tenStr+ bigStr[k][9]

#print(twoStr)

#print (len(oneStr))

    return oneStr,twoStr,threeStr,fourStr,fiveStr,sixStr,sevenStr,eightStr,nineStr,tenStr

#判断连续出现的次数

def doPanduan(str):

    if 'j' in str:

        str= str.replace('j','d')

str= str.replace('o','x')

twelveNumd= str.count('dddddddddddd')

twelveNumx= str.count('xxxxxxxxxxxx')

twelveNum= twelveNumx+ twelveNumd

elevenNumd= str.count('ddddddddddd')

elevenNumx= str.count('xxxxxxxxxxx')

elevenNum= elevenNumx+ elevenNumd- twelveNum* 1

    tenNumd= str.count('dddddddddd')

tenNumx= str.count('xxxxxxxxxx')

tenNum= tenNumx+ tenNumd- twelveNum* 1 - elevenNum* 1

    nineNumd= str.count('ddddddddd')

nineNumx= str.count('xxxxxxxxx')

nineNum= nineNumx+ nineNumd- twelveNum* 1 - elevenNum* 1 - tenNum*1

    eightNumd= str.count('dddddddd')

eightNumx= str.count('xxxxxxxx')

eightNum= eightNumx+ eightNumd- twelveNum* 1 - elevenNum* 1 - tenNum*1-nineNum*1

    sevenNumd= str.count('ddddddd')

sevenNumx= str.count('xxxxxxx')

sevenNum= sevenNumx+ sevenNumd- twelveNum* 1 - elevenNum* 1 - tenNum*1-nineNum*1-eightNum*1

    sixNumd= str.count('dddddd')

sixNumx= str.count('xxxxxx')

sixNum= sixNumx+ sixNumd- twelveNum* 2 - elevenNum* 1 - tenNum*1-nineNum*1-eightNum*1-1*sevenNum

fiveNumd= str.count('ddddd')

fiveNumx= str.count('xxxxx')

fiveNum= fiveNumx+ fiveNumd- twelveNum* 2 - elevenNum* 2 - tenNum*2-nineNum*1-eightNum*1-1*sevenNum-1*sixNum

fourNumd= str.count('dddd')

fourNumx= str.count('xxxx')

fourNum= fourNumx+ fourNumd- twelveNum* 3 - elevenNum* 2 - tenNum*2-nineNum*2-eightNum*2-1*sevenNum-1*sixNum-fiveNum*1

    threeNumd= str.count('ddd')

threeNumx= str.count('xxx')

threeNum= threeNumx+ threeNumd- twelveNum* 4 - elevenNum* 3 - tenNum*3-nineNum*3-eightNum*2-2*sevenNum-2*sixNum-fiveNum*1-fourNum*1

    twoNumd= str.count('dd')

twoNumx= str.count('xx')

twoNum= twoNumx+ twoNumd- twelveNum* 6 - elevenNum* 5 - tenNum*5-nineNum*4-eightNum*4-3*sevenNum-3*sixNum-fiveNum*2-fourNum*2-threeNum*1

    oneNumd= str.count('d')

oneNumx= str.count('x')

oneNum= oneNumx+ oneNumd- twelveNum*12 - elevenNum*11 - tenNum*10-nineNum*9-eightNum*8-7*sevenNum-6*sixNum-fiveNum*5-fourNum*4-threeNum*3 \

-twoNum*2

    print(twelveNum,elevenNum,tenNum,nineNum,eightNum,sevenNum,sixNum,fiveNum,fourNum,threeNum,twoNum,oneNum)

if __name__== '__main__':

    bigStr= getAll()

#print(len(bigStr))

#判断大小的数据 0

    allStrdx= doHeBing(bigStr[0])

# 判断奇偶数的数据 1

    allStrjo= doHeBing(bigStr[1])

print(allStrdx[1])

for iin range(0,10):

        doPanduan(allStrdx[i])

doPanduan(allStrjo[i])

你可能感兴趣的:(daxiao jiou)