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 ...
随机推荐
- (三)使用链式数据实现包(java)
目标: 1) 描述数据的链式组织方式 2) 描述如何在链式节点链的开头添加新节点 3) 描述如何删除链式节点链的首节点 4) 描述如何在链式节点链中找到某个数据 5) 使用链式节点链实现ADT包 6) ...
- Oracle中序列(Sequence)详解
一 序列定义 序列(SEQUENCE)是序列号生成器,可以为表中的行自动生成序列号,产生一组等间隔的数值(类型为数字).不占用磁盘空间,占用内存. 其主要用途是生成表的主键值,可以在插入语句中引用,也 ...
- MapReduce(一)
MapReduce(一) 一.介绍 百度百科: MapReduce是一种编程模型,用于大规模数据集(大于1TB)的并行运算.概念"Map(映射)"和"Reduce(归约) ...
- E - Let's Go Rolling!
题目描述:数轴上有nn个质点,第ii个质点的坐标为xixi,花费为cici,现在要选择其中一些点固定,代价为这些点的花费,固定的点不动,不固定的点会向左移动直至遇到固定的点,代价是这两点的距离,如果左 ...
- Cppcheck - A tool for static C/C++ code analysis
cppcheck是一个个检测源码的工具,对编译工具的一个补充,mark Cppcheck - A tool for static C/C++ code analysis Syntax: cppchec ...
- 微信小程序: rpx与px,rem相互转换
官方上规定屏幕宽度为20rem,规定屏幕宽为750rpx,则1rem=750/20rpx. 微信官方建议视觉稿以iPhone 6为标准:在 iPhone6 上,屏幕宽度为375px,共有750个物理像 ...
- Windows开启远程桌面服务(Win10)
进入控制面版,找到远程设置 应用确定后Windows服务即会被启动.
- this 锁与 static 锁
一. this 锁 同步函数其实用到的锁就是 this 锁,为什么他用到的是 this 锁呢?为了证实这个结论我 们本节将会有两个实验性的程序来作为支撑,说服自己和读者证明同步函数用到的就是 this ...
- BPTT for multiple layers
单层rnn的bptt: 每一个时间点的误差进行反向传播,然后将delta求和,更新本层weight. 多层时: 1.时间1:T 分层计算activation. 2.时间T:1 利用本时间点的误差,分层 ...
- laravel中对模型和路由做缓存,提高性能
模型缓存命令: php think optimize:schema 路由缓存命令: php think optimize:route