“百度杯”CTF比赛 十二月场misc1-纵横四海
#python3
import os,sys
# 列出当前目录下所有的文件
path="C:/Users/Sun/Desktop/tiaoxiwoya"
files = os.listdir(path) # 如果path为None,则使用path = '.'
a=str('')
for filename in files:
portion = os.path.splitext(filename) # 分离文件名与扩展名
# 如果后缀是jpg
if portion[1] == '':
# 重新组合文件名和后缀名
newname = portion[0] + '.txt'
f=path+'/'+filename
os.rename(f, newname)
with open(filename+'.txt') as file_obj:
content = file_obj.read()
a = a + str(content)
print(a.replace("\n", ""))
最新评论