Sunday, September 8, 2019

markdown - Writing from .txt to .md in python




How can I read a .txt file in python and write those contents into a .md file without any change in content. I have googled enough but couldn't find a proper answer . ?


Answer




If you're not changing the contents you could just change the file extension. See this SO answer for help



Change the file extension for files in a folder in Python



Edited based on comment
If you want to make a copy this is the simplest way I believe



import shutil
shutil.copyfile("testcopy.txt", "testcopy.md")


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...