Python script to read from arduino micro hid keyboard

Arduino micro can be used as HID keyboard . I want to use Arduino micro as HID keyboard and read the data from arduino micro by python instead of python serial .

I'm using following code for arduino micro :

#include "Keyboard.h"

void setup() 
{
  
  pinMode(4, INPUT);
  // initialize control over the keyboard:
  Keyboard.begin();

}

void loop() 
{
  if(digitalRead(4)==1)
  {
    delay(200);
    Keyboard.println("Hello WOrld!");
  }
  delay(200);
}

I want to connect arduino micro via python script as HID device and receive ""Hello WOrld!". How to do this ?

If you are using the Micro to pretend it is a PC keyboard then as far as your Python program is concerned there will be no Arduino - just a keyboard so you need to write the same Python code that you would use if the characters were being typed on the real keyboard.

...R