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 ...
随机推荐
- 3月25 JavaScript 练习题
一个关于找7的题 <script type="text/javascript" language="javascript"> for(var i=1 ...
- vivado实现模16的计数器
`timescale 1ns / 1ps module ctr_mod_16( clk, rst_n, count ); input clk, rst_n; :] count; wire clk, r ...
- CCF-CSP 201312-5 I'm stuck !
I'm stuck 试题编号: 201312-5 试题名称: I’m stuck! 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 给定一个R行C列的地图,地图的每一个方格可能 ...
- servlet初认知(持续更新中)
一:前言: 一个Servlet程序其实就是一个实现了Java特殊接口的类,它由支持Servlet(具有Servlet引擎)的WEB服务器调用和启动运行.一个Servlet程序负责处理它对应的一个或者多 ...
- net core 上传并使用EPPlus导入Excel文件
1. cshtml页面 form <form id="form" method="post" action="/SaveValueBatch& ...
- vs2015 出现Lc.exe 已退出,代码为-1的问题,如何解决
今天在代码运行时,出现lc.exe已退出,代码为-1 的问题
- linux下详解shell中>/dev/null 2>&1
前言 相信大家经常能在shell脚本中发现>/dev/null 2>&1这样的语句.以前的我并没有去深入地理解这段命令的作用,照搬照用,直到上周我将这段命令不小心写成了2>& ...
- 遍历所有子物体中renderer(渲染器)中的material(材质)并改变其alpha值实现若隐若现的效果
using UnityEngine;using System.Collections;using UnityEngine.UI; public class CubeControl : MonoBeha ...
- 回溯算法 LEETCODE别人的小结 一八皇后问题
回溯算法实际上是一个类似枚举的搜索尝试过程,主要是在搜索尝试中寻找问题的解,当发现已不满足求解条件时,就回溯返回,尝试别的路径. 回溯法是一种选优搜索法,按选优条件向前搜索,以达到目的.但是当探索到某 ...
- linux-安装jdk以及tomcat
1.安装jdk 下载地址:www.oracle.com/technetwork/cn/java/javase/downloads/jdk7-downloads-1880260.html 将jdk下 ...