# 替换敏感字符,统计,乘法表,函数

#!/usr/bin/env python# -*- coding:utf-8 -*-# 1.替换敏感字符# keys = ['苍老师', '小泽老师', 'alex']# with open('file.txt', mode='r', encoding='utf-8') as f1, open('2.txt', mode='w', encoding='utf-8') as f2:#     for line in f1:#         for a in keys:#             if a in line:#                 line = line.replace(a, '***')#         f2.write(line)# 2.统计各省车牌数# cars = ['鲁A3244','鲁B12333','京B8989M','黑C49678','黑C46555','沪B25041','黑C34567']# dic = {}# for i in cars:#     a = i[0]#     if a in list(dic.keys()):#         dic[a] += 1#     else:#         dic[a] = 1# print(dic)# 3.数据添加到字典.# info = []# with open('data.txt',mode='r',encoding='utf-8') as f1:#     a = f1.readline()#     for lines in f1:#         dic = {}#         i = lines.split(',')#         count = 0#         for k in a.split(','):#             dic[k.strip()] = i[count].strip()#             count += 1#         info.append(dic)# print(info)# 4.小九九乘法表# for a in range(1,10):#     for b in range(1,a+1):#         if a == b:#             print(str(a) + '*' + str(b))#         else:#             print(str(a)+'*'+str(b),end=' ')# 5.读取文件，将文件的内容构造成指定格式的数据，并返回。# """# a.log文件#     alex|123|18#     eric|uiuf|19#     ...# 目标结构：# a.  ["alex|123|18","eric|uiuf|19"] 并返回。# b. [['alex','123','18'],['eric','uiuf','19']]# c. [#  {'name':'alex','pwd':'123','age':'18'},#  {'name':'eric','pwd':'uiuf','age':'19'},# ]'''def func1():     lst = []     with open('a.log', mode='r', encoding='utf-8') as f:         for line in f:             lst.append(line.strip())     return lst print(func1())''''''def func2():    lst = []    with open('a.log', mode='r', encoding='utf-8') as f:    for line in f:        a = line.strip().split('|')        lst.append(a)return lst''''''def func3():    lst = []    with open('a.log', mode='r', encoding='utf-8') as f:        for line in f:            dic = {}            a, b, c = line.strip().split('|')            dic['name'] = a            dic['pwd'] = b            dic['age'] = c            lst.append(dic)    return lstprint(func3())'''# 6.不用max和min找出最大最小值.'''def func(*args):    ma = args[0]    mi = args[0]    for i in args:        if i > ma:            ma = i        if i < mi:            mi = i    return {'最大值':ma,'最小值':mi}print(func(1,6,8,7,1,2,4))'''# 传入n,返回n的阶乘.'''def func(n):    res = 1    for i in range(1, n+1):        res *= i    return resprint(func(7))'''

11-19 591

06-20 41
06-06 3620
10-28 723
08-12 5439
07-09 2986
07-19 1409
07-31 611
06-17 63
07-12 1050
09-03 410
09-28 222
05-19 261