Write a Python program to create a copy of its own source code.

Write a Python program to create a copy of its own source code.

1
2
3
4
5
6
7
def file_copy(src, dest):
    with open(src) as f, open(dest, 'w') as d:
        d.write(f.read())
        file_copy("untitled0.py", "z.py")
        with open('z.py', 'r') as filehandle:
            for line in filehandle:
                print(line, end = '')

Final output

Leave a Comment