python day08作业答案
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作业答案的更多相关文章
- 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= ...
- 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 ...
- python day08作业
- 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 ...
- python day06 作业答案
1. count=1 while count<11: fen=input('请第{}个评委打分' .format( count)) if int(fen) >5 and int(fen) ...
- python day05 作业答案
1. b.不可以 c.tu=("alex",[11,22,{"k1":"v1","k2":["age" ...
- python day04 作业答案
1. 1) li=['alex','WuSir','ritian','barry','wenzhou'] print(len(li)) 2) li=['alex','WuSir','ritian',' ...
- 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) ...
- 笔试 - 高德软件有限公司python问题 和 答案
高德软件有限公司python问题 和 答案 本文地址: http://blog.csdn.net/caroline_wendy/article/details/25230835 by Spike 20 ...
随机推荐
- python迭代器概念与应用
结论 )可迭代对象包含迭代器.2)如果一个对象拥有__iter__方法,其是可迭代对象:如果一个对象拥有next方法,其是迭代器.3)生成器是一种特殊的迭代器,生成器自动实现了“迭代器协议”(即__i ...
- PostgreSQL常用函数
1.系统信息函数 1.会话信息函数 edbstore=# select current_catalog; #查询当前数据库名称 current_database ------------------ ...
- [hdu 6191] Query on A Tree
Query on A Tree Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 132768/132768 K (Java/Othe ...
- Caused by: java.io.FileNotFoundException: class path resource [spring/springmvc.xml] cannot be opene
Caused by: java.io.FileNotFoundException: class path resource [spring/springmvc. ...
- Humble Numbers HDU - 1058
A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, ...
- Linux几种服务用处介绍
rexec--Remote Execute,远程命令执行,允许远程机器在本机上远程执行命令,监听端口512. nfs--Network File System,网络文件系统,用于将本机文件夹共享到别的 ...
- @Configuration的使用 和作用
1从spring4.0以后,@Spring boot Application就包含了@ComponentScan,@ComponentScan就不用写了 2@MapperScan(basePackag ...
- latex 公式距离
\setlength{\abovedisplayshortskip}{0cm} 公式和文本之间的间距 \setlength{\belowdisplayshortskip}{0cm} \setlengt ...
- 2-MAVEN 基本命令
MVN的基本命令 mvn package:打包 >生成了target目录 >编译了代码 >使用junit测试并生成报告 >生成代码的jar文件 >运行jar包: java ...
- vue中的axios
数据的获取最常用的就是用ajax,但在vue框架中,axios则更为方便.它是基于es6的promise 以下内容引用自[最骚的就是你] 不再继续维护vue-resource,并推荐大家使用 axio ...