1.
a
f=open('11.txt','r',encoding='utf-8')
a=f.read()
print(a)
f.flush()
f.close()
b.
f=open('11.txt','a',encoding='utf-8')
f.write('信不信由你')
f.flush()
f.close()
c.
f=open('11.txt','r+',encoding='utf-8')
a=f.read()
print(a)
f.write('信不信由你')
f.flush()
f.close()
d.
f=open('11.txt','w',encoding='utf-8')
f.write('每天坚持一点')
f.flush()
f.close()
e.
f1=open('11.txt','r',encoding='utf-8')
f2=open('11.1','w',encoding='utf-8')
a=f1.readline()
b=f1.readline()
c=f1.readline()
d=f1.readline()
f2.write(a)
f2.write(b)
f2.write(c)
f2.write('你们就信了吧。')
f2.write(d) 2.
a,b
with open('t1.txt','r+',encoding='utf-8') as f1:
a=f1.read()
f1.write('a')
for line in a:
print(line)
c.
with open('t1.txt','r',encoding='utf-8') as f1:
a=f1.readlines()
for line in a:
print(line)
d.
with open('t1.txt','r',encoding='utf-8') as f1:
a=f1.read(4)
print(a) e.
with open('t1.txt','r',encoding='utf-8') as f1:
a=f1.readline()
a.replace(' ','')
a.replace('/n','')
print(a)
f.
with open('t1.txt','r',encoding='utf-8') as f1:
a=f1.readline()
b=f1.readline()
c=f1.readline()
print(c) g.
with open('t1.txt','a+',encoding='utf-8') as f1: f1.write('老男孩教育')
f1.seek(0)
a=f1.read()
print(a) h.
with open('t1.txt','r',encoding='utf-8') as f1:
a = f1.read()
print(a)
3.
b=[]
with open('a.txt','r',encoding='utf-8') as f1:
df=f1.readlines()
for i in range(0,len(df)):
a = {}
a['name']=df[i].replace('\n','').split(' ')[0]
a['price'] = df[i].replace('\n','').split(' ')[1]
a['amount'] = df[i].replace('\n','').split(' ')[2]
b.append(a)
print(b) 4.
f1= open('4.txt','r',encoding='utf-8')
f2=open('4.1.txt','w+',encoding='utf-8')
a=f1.read()
c=a.replace('alex','SB')
f2.write(c)
5.
lst=[]
f1= open('a.txt','r',encoding='utf-8')
for i in f1:
lst1=i.split()
print(lst1)
dic={}
dic[lst1[0].split(':')[0]]=lst1[0].split(':')[1]
dic[lst1[1].split(':')[0]]=lst1[1].split(':')[1]
dic[lst1[2].split(':')[0]] =lst1[2].split(':')[1]
dic[lst1[3].split(':')[0]] = lst1[3].split(':')[1]
lst.append(dic)
print(lst)
6.
lst=[]
f1= open('a.txt','r',encoding='utf-8')
a=f1.readline().split()
print(a)
for i in f1:
dic={}
print(i)
dic[a[0]]=i.split()[0]
dic[a[1]]=i.split()[1]
dic[a[2]]=i.split()[2]
lst.append(dic)
print(lst)

python day08作业答案的更多相关文章

  1. python day10作业答案

    2.def func(*args): sum = 0 for i in args: sum=sum+int(i) return sum a=func(2,3,9,6,8) print(a) 3. a= ...

  2. python day09作业答案

    2. def lst(input): lst2=[] count=0 for i in range(0,len(input)): if i %2!=0: lst2.append(input[i]) r ...

  3. python day08作业

  4. python day07作业答案

    1. sum=0 a=input() for i in a: sum=sum+int(i)**3 if sum==int(a): print('水仙数') 2. lst=[100,2,6,9,1,10 ...

  5. python day06 作业答案

    1. count=1 while count<11: fen=input('请第{}个评委打分' .format( count)) if int(fen) >5 and int(fen) ...

  6. python day05 作业答案

    1. b.不可以 c.tu=("alex",[11,22,{"k1":"v1","k2":["age" ...

  7. python day04 作业答案

    1. 1) li=['alex','WuSir','ritian','barry','wenzhou'] print(len(li)) 2) li=['alex','WuSir','ritian',' ...

  8. python day02 作业答案

    1. (1).false   (2).false 2. (1).8  (2).4 3. (1).6  (2).3  (3).false (4).3   (5).true   (6).true  (7) ...

  9. 笔试 - 高德软件有限公司python问题 和 答案

    高德软件有限公司python问题 和 答案 本文地址: http://blog.csdn.net/caroline_wendy/article/details/25230835 by Spike 20 ...

随机推荐

  1. 时间选择控件YearPicker(基于React,antd)

    不知道为什么蚂蚁金服团队没有在ant design的DatePicker中单独给出选择年份的组件,这给我们这种懒人造成了很大的痛苦,自己手造轮子是很麻烦的.毕竟只是一个伸手党,emmmmm..... ...

  2. csu oj 1342: Double

    Description 有一个由M个整数组成的序列,每次从中随机取一个数(序列中每个数被选到的概率是相等的)累加,一共取N次,最后结果能被3整除的概率是多少? Input 输入包含多组数据.     ...

  3. Git:从远程库克隆到本地库及更新本地库

    1.例如我们克隆远程库gitskills 2.克隆 2.1选择合适的地方(文件目录),点击Git Bash Here. 2.2如果是github远程库,进行以下操作: 点击gitskills,再点击红 ...

  4. loj 10000 活动安排

    ****这是一个贪心题,把结束时间排个序,然后留出更多的时间给后面的活动. #include<cstdio> #include<cstring> #include<alg ...

  5. PHPCMS V9完全开发介绍

    PHPCMS V9 文件目录结构: 根目录 | – api 接口文件目录 | – caches 缓存文件目录 | – configs 系统配置文件目录 | – caches_* 系统缓存目录 | – ...

  6. JS--理解参数,argument,重载

    ECMAScript函数的参数与大多数其他语言函数的参数不同.ECMAScript函数不介意传递进来多少个参数,也不在乎传递进来的参数是什么数据类型. 原由在于,ECMAScript中的参数在内部是用 ...

  7. python 转换代码格式

    import os dirname="C:\\Users\\haier\\Desktop\\new" def walk(path): for item in os.listdir( ...

  8. HDU 1005 Number Sequence(数论)

    HDU 1005 Number Sequence(数论) Problem Description: A number sequence is defined as follows:f(1) = 1, ...

  9. 最佳加法表达式(dp)

    题目描述: 有一个由1..9组成的数字串.问如果将m个加 号插入到这个数字串中,在各种可能形成的 表达式中,值最小的那个表达式的值是多少 (本题只能用于整数) 解题思路: 假定数字串长度是n,添完加号 ...

  10. CAD(布置厨洁具)(尺寸标注)5.12

    "TYTK"打开图库,找到平面厨具和洁具.双击选中的厨具,A可以不停旋转90度.给厨具选取正确的位置.画出灶台线,同理画出卫生间的家具.绘制出洗脸台的平台.浴缸的平台. 尺寸标注: ...