How to connect a PLC to a Python script running on the computer

Hi,
I have a Python script running on my PC and I would like this script to communicate with the PLC which is also connected to the PC but I am not sure how to approach it, do it indirectly via some server or directly. Do you have any advice on how to do it best?

Hello,
Rest API, TCP/TLS ports. This two options come on mind for direct connection.
Best regards.

or OPC UA, if there is a suitable OPC UA client library available for Python.

You also can use our RSC library which is developed for exchanging data between Py and PLCnext runtime.

or OPC UA, if there is a suitable OPC UA client library available for Python.</p>

https://github.com/FreeOpcUa/opcua-asyncio