How to replace these paths with Python?
These linked files are in:
bpy.data.libraries

You can have their filepath with for instance:
[lib.filepath for lib in bpy.data.libraries]

The path is relative to the current blend file, so you can have absolute path with:
[bpy.path.abspath(lib.filepath) for lib in bpy.data.libraries]

In the documentation:

Libraries
Path utilities