'How to open a file with a specific application by python?

For example, I want to open a file D:\happy\0.pyw My code is below

import os

def open_app(dir):
    os.startfile(dir)

if __name__ == "__main__":
    b=r'D:\happy\0.pyw'
    open_app(b)

But here I want to edit the file with IDLE, not just click open it. How to change the code?

b=r'D:\happy\0.pyw'

with

D:\python\idle.pyw'

will fail.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source