|
发表于 2024-6-29 15:50:34
|
显示全部楼层
请回复您的答案^_^
-------- 问答题 --------
第 0 题的答案是:会
第 1 题的答案是:用w模式打开
第 2 题的答案是:调用3个字符
第 3 题的答案是:3
第 4 题的答案是:因为写入的时候字符之间有一次自动换行
第 5 题的答案是:反斜杠被认为时转义字符
第 6 题的答案是:这个文档里的内容需要被覆盖而不是修改
第 7 题的答案是:可以
第 8 题的答案是:指向文件内的内容
第 9 题的答案是:文件末尾,或者无数据可读
第 10 题的答案是:用file.tell()
-------- 动动手 --------
请将第 0 题的代码写在下方:
with open('C:\\Users\\baozengye\\Downloads\\ctf题目\\FishC.txt','r')as file:
content =file.read()
conten2=content[9:15]
with open ('C:\\Users\\baozengye\\Downloads\\ctf题目\\FishC.txt','w')as file:
file.write(conten2)
print("finished")
请将第 1 题的代码写在下方:
with open('C:\\Users\\baozengye\\Downloads\\ctf题目\\FishC.txt','r')as file:
content =file.read()
conten2=content[0:15]
with open ('C:\\Users\\baozengye\\Downloads\\ctf题目\\FishC.txt','w')as file:
file.write(conten2)
print("finished")
请将第 2 题的代码写在下方:
script_path=__file__
try:
with open(script_path,'r') as file:
lines=file.readlines()
for line in lines:
print(line,end='')
except Exception as e:
print(f"error:{e}")
请将第 3 题的代码写在下方:
from PIL import Image
import zipfile
import io
image_path="C:\\Users\\baozengye\\Desktop\\hw\\test.jpg"
zip_path="C:\\Users\\baozengye\\Desktop\\hw\\target.zip"
with Image.open(image_path) as img:
image_bytes_io =io.BytesIO()
img.save(image_bytes_io,format='JPEG')
image_bytes_io.seek(0)
image_bytes =image_bytes_io.getvalue()
with zipfile.ZipFile(zip_path,'r')as zip_file:
zip_contents=b''
for entry in zip_file.infolist():
with zip_file.open(entry)as file:
zip_contents +=file.read()
steg_image_bytes=image_bytes + zip_contents
steg_image_bytes_io=io.BytesIO(steg_image_bytes)
steg_image_path='C:\\Users\\baozengye\\Desktop\\hw\\steg_image_png'
steg_image_bytes_io.seek(0)
steg_image=Image.open(steg_image_bytes_io)
steg_image.save(steg_image_path,'JPEG')
print("succes |
|