WINDOWS_LINE_ENDING = b’\r\n’
UNIX_LINE_ENDING = b’\n’
relative or absolute file path, e.g.:
file_path = r"/Users/chen/Documents/GitHub/darknet/dataset/train.txt"
with open(file_path, ‘rb’) as open_file:
content = open_file.read()
content = content.replace(WINDOWS_LINE_ENDING, UNIX_LINE_ENDING)
:
with open(file_path, ‘wb’) as open_file:
open_file.write(content)