如何将字符串拆分为字母

How to split a string into letters

我需要导入一个 2 行的 txt 文件并将文件中的每个 "e" 更改为 "bob" 我知道您从以下内容开始,但我很难将字符串中的单词变成一串字母,以便我可以使用 .replace("e","bob") 方法。

txt文件如下:

Hey Jim, how are you doing today?
I hope all is well with you.

我的代码如下:

text = open(input("Enter file name"), "r")
textline = text.readlines()

numline = 0

for line in textline:
    numline = numline + 1
    textword = line.split()
    lineletter = list(line)
    z = str(lineletter)
    q = z.replace('e', 'zw')

    print(lineletter)
    print(textword)
    print(z)

从这里到哪里去?

你不需要去分裂只是更换就足够了。

with open("file", 'r') as f:
    for line in f:
        print(line.replace('e', 'bob'), end="")