Skip to content
Advertisement

How to open and edit a file with .pas format which can be opened by Text editor or Notepad++ in Python? [closed]

I would like to open a .pas file in Python, ( Generally, I can open the .pas by Text Editor to see what is inside). So, I am looking for the code to open and edit the file in Python. To more clear, I would like to edit some variables in the file. So first I need to open it and then edit the file.

Advertisement

Answer

You can use the builtin open() function to open a text file:

with open('file.pas', mode='r') as f:
    print(f.read())

Here are the docs

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement