猫史档案馆


【Python作品分享】关于对文件进行操作1【作业帖】

用户:鸽子ECYRAZ鸽子ECYRAZ查看:0 回复:0 评论:0 创建时间:2020-10-16T20:18:23


【作品展示】

center_image

 

【作品介绍】

1

 

【作品源代码】

"""
#编辑打开的文件
a=open('随便做的.txt','a')
a.write('我叫')
a.write(input('姓名'))
a.write('我的年龄是')
a.write(input('你的年龄'))
a.close()

a = input('姓名')
b = input('年龄')
c = input('性别')
d = open('随便建的.txt', 'w')
f = '我叫'+a+'我今年'+b+'我的性别是'+c
print(f)
e = d.write(f)
d.close()

#with open用法
with open('随便做的.txt', 'a') as a:
    a.write('我叫')
    a.write(input('姓名'))
    a.write('我的年龄是')
    a.write(input('你的年龄'))
    
"""
#打开图片以及如何打开部分文件
with open('timg[3].jpg','rb') as a:
    c=a.read()
with open('timg[4].jpg','wb') as b:
    b.write(c[:len(c)//8])

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页