分类:python
将一个列表数据写入output.xlsx的a,b,c……等sheet中importpandasaspddf1=pd.DataFrame({'a':[3,1],'b':[4,3]})df2=df1.copy()withpd.ExcelWriter('F:\\python入门\\数据2\\output.xlsx')aswriter:str1=['a','b','c','d','e','f','g','h','i',\'j','k','l','m','n','o','p','q']foriinstr1:name=str(i)df1.to_excel(writer,sheet_name=name)writer.save()writer.close()结果此时每个sheet的...
继续阅读 >
本文为大家解析了python实现4名牌手洗牌发牌的问题,供大家参考,具体内容如下编写程序,4名牌手打牌,计算机随机将52张牌(不含大小鬼)发给4名牌手,在屏幕上显示每位牌手的牌。创建函数gen_pocker()交换牌的顺序,函数getColor()获取牌的花色,函数getValue()获取牌的牌面大小,函数getPuk()获取花色和牌面大小的组合运行效果[51,45,31,4,48,26,11,2,24,44,22,21,16,41,50,47,13,25,17,29,42,27,19,33,...
继续阅读 >
可迭代对象去重(保持顺序不变)deffilter_multi(items,key=None):"""可迭代对象去重(保持顺序不变)[1,4,7,2,4,7,3,5]==>[1,4,7,2,3,5]"""its=list()forxinitems:val=xifkeyisNoneelsekey(x)ifvalnotinits:yieldvalits.append(val)#如:printlist(filter_multi([1,3,5,3,7,2,4,2]))items=[{'a':1,'b':2},{'a':3,'b':4},{'a':1,'b':2},{'a':5,'b':6}]printlist(filter_multi(items,key=lambdak...
继续阅读 >
2020
09-29