operating systems – How to write a program that works in different operating systems?

The question I ask is not clear, I think it's a bit difficult to explain with just one line. Here is my situation: I have a Bitbucket repertoire that is cloned both in a Linux environment and in Windows. The problem I have is:

1- I need to read and write from files and the routes to the different locations must be changed every time I commit and press. Therefore, if I was working on Windows and did an impulse, when I go back to Linux and I need to activate and change the routes I used.

2- I am running selenium with Python. To make it work on my Linux machine without a server, I need to create a virtual screen with the pyvirtualdisplay library. Therefore, some codes that must be run on my Linux machine should not be run on my Windows machine.

So, the problem I have is that if I work on my Windows machine, I need to comment on the lines that create the virtual screen.

These two problems take a long time, because every time I connect to a different machine, I can not work directly on the code, but first I must change the code.