将一个文件中的所有人名首字母转换成大写,复制到另一个文件中 要求先将同宿舍其他人的名字用拼音写入一个文件roommates.txt,再创建一个新文件Roommates.txt保存转换首字母后的人名
txt = '' with open('roommates.txt', 'r') as f: txt = f.read() with open('Roommates.txt', 'a+') as f: f.write(txt.title())