写了一个备份文件的代码,但是到最后一步的时候,备份文件的写入失败,请教下问题在哪里,debug了也查不出


"""新建并存储原始文件"""
oldFile_path = 'D:\\python测试文件夹\\'  # 设置自定义保存的文件夹位置
old_id = input("请输入原始文件名:")  # 原始文件名称
if '.txt' in old_id:
    print("文件名不规范")
    exit()
elif '.doc' in old_id:
    print("文件名不规范")
    exit()
elif '.ppt' in old_id:
    print("文件名不规范")
    exit()
elif '.xls' in old_id:
    print("文件名不规范")
    exit()
else:
    pass
 
 
def save_fileFormat(i):
    """设置文件保存类型"""
    if i == '文档':
        return '.doc'
    elif i == '表格':
        return '.xls'
    elif i == '幻灯片':
        return '.ppt'
    elif i == '记事本':
        return '.txt'
    else:
        print("请按照输入正确的文件保存类型:[文档]/[幻灯片]/[记事本]/[表格]")
        help(save_fileFormat)
        exit()
 
 
oldId = oldFile_path + old_id + save_fileFormat(
    i=input("请文件保存类型:"))  # 输入文件格式(后缀)
 
print('原始文件为名为%s' % oldId)
old_fileObject = open(oldId, 'w')
content_old = input('请输入数据:')
old_fileObject.write(content_old)
 
"""自定义备份文件"""
searchFormat = oldId.rfind('.')
backup_fileName = input("请输入备份文件名:")
backupID = oldFile_path + backup_fileName + save_fileFormat(i=input("请文件保存类型:"))
# print("源文件的格式后缀在%s" % searchFormat)
backup_fileObject = open(backupID, 'w+')
print("源文件已完毕,请开始备份文件写入")
"""读写文件"""
old_f = open(oldId, 'r')
content_backup = old_f.read(99999)
print(content_backup)
new_f = open(backupID, 'w+')
new_f.write(content_backup)
new_f = open(backupID, 'r')
new_f.read(99999)
print(new_f.read(99999))
 

前面都正常运行的,最后一步,【读写文件】开始,这几行代码似乎不起作用,新建的文件一片空白,请问到底问题出现在哪里

因为ppt等格式需要用2进制解码
把r改成rb,w改成wb
个人不推荐使用w+