param = "A\rB\nC\r\nD"
r = param.replace('\r', '')
n = param.replace('\n', '')
rn1 = param.replace('\n', '').replace('\r', '')
rn2 = param.replace('\r\n', '')
print(r)
print("=================================")
print(n)
print("=================================")
print(rn1)
print("=================================")
print(rn2)
# 結果
#AB
#C
#D
#=================================
#DC
#=================================
#ABCD
#=================================
#B
#CD
More than 3 years have passed since last update.
改行コード入り文字列を"\r"、"\n"、"\r\n"でそれぞれ文字列変換(replace)してみた結果
Last updated at Posted at 2021-10-01
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme