Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我在 Ren'py 中制作了一个相当大的游戏,其中包含很多来自字符的字母,并且因为我不想创建一个被 5000 行字母阻塞的 rpy 文件,所以我将它们存储在纯文本文件中反而。
但是,我想在将它们导入游戏时保持格式,所以我想将它们作为多行字符串导入。导入游戏时如何保留txt文件中的格式?
即当我将它作为多行字符串导入时,我想保留 txt 文件中的每个换行符(只是格式化为普通的旧换行符,而不是 \n 或任何东西)。
您可以一次读取整个文件:
with open("file.txt", "r") as file: message = file.read()
这将保留原始文件内容。