0
4

1 回答 1

1

You can try this, I have modified your code a little bit:

def translate_function(file):
    filea = open(file,encoding = "utf8")
    fileb = open("lmao.txt", 'r+')
    count = 0
    for i in filea:
        state = 'false'
        count += 1
        words = i.split(" ")
        for word in words:
            if not word.isalpha():
                trans = translate(i)
                fileb.write(trans)
                fileb.write('\n')
    return count
于 2018-06-22T03:18:19.947 回答