picd = {} numd = {} fi = open("dir_100.txt",'r') for stulists in fi: stulists = stulists.replace('\n','').、____ if stulists [0] != '' : lkey,lvalue = ___,eval(stulists [0]) lval = [] for v in lvalue: if v != ___: lval.append(v) if lval: lv= ','. ___ print("{}:{}".format( lkey,lv)) picd[lkey] = ___ fi.close() idd = {} for key in picd: ids = picd[key]. ___ for num in ids: idd[num] = idd. ___ +1 s = 0 for key in idd: s += int(___) count = ___ print("实际参加测试的人数是:",count) print("人均被测次数是:{:.1f}".format(s/count))
时间: 2024-02-24 10:59:10 浏览: 144
picd:Picd是基本的摄影比赛
以下是代码的完整版:
```python
picd = {}
numd = {}
fi = open("dir_100.txt",'r')
for stulists in fi:
stulists = stulists.replace('\n','')
if stulists [0] != '' :
lkey,lvalue = stulists.split('_')
lvalue = eval(lvalue)
lval = []
for v in lvalue:
if v != '0':
lval.append(v)
if lval:
lv= ','.join(lval)
print("{}:{}".format( lkey,lv))
picd[lkey] = lval
fi.close()
idd = {}
for key in picd:
ids = picd[key]
for num in ids:
idd[num] = idd.get(num,0) + 1
s = 0
for key in idd:
s += int(idd[key])
count = len(idd)
print("实际参加测试的人数是:",count)
print("人均被测次数是:{:.1f}".format(s/count))
```
运行结果应该和前面的一样。
阅读全文