首先,您需要打开文档并将其读入内存。您可以使用 Python 的内置函数 open() 来打开文件并将其读入字符串变量,例如: with open('world.txt', 'r') as f: content = f.read()