物理の駅 Physics station by 現役研究者

テクノロジーは共有されてこそ栄える

PythonでWindowsの文字コード CRLF (\r\n)から、Linuxの文字コードLF(\n)へ変換する

txt = open(target_file, 'r', encoding='utf-8').read().replace('\r', '')
with open(target_file, 'wb') as f:
    f.write(txt.encode('utf-8'))