Sunday, 8 September 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...