我有这个代码贯穿文本文件中的行,如下所示:
09824747 18 n 02 archer 0 bowman 0 003 @ 09640897 n 0000 ~ 10290474 n 0000 ~i 10718145 n 0000 | a person who is expert in the use of a bow and arrow
L = line.split()
L2 = line.split('|')
synset_offset = L[0]
lex_filenum = L[1]
ss_type = L[2]
gloss = L2[1]
我打印这些的方式看起来像这样
print('''<http://example.org/#'''+synset_offset+'''><http://www.monnetproject.eu/lemon#lex_filenum> "'''+lex_filenum+'''".
<http://example.org/#'''+synset_offset+'''> <http://www.monnetproject.eu/lemon#ss_type> "'''+ss_type+'''".
<http://example.org/#'''+synset_offset+'''> <http://www.monnetproject.eu/lemon#gloss> "'''+gloss+'''".''')
但由于某种原因,之后会出现换行符'''+gloss+'''
看起来像这样
<http://example.org/#09824747> <http://www.monnetproject.eu/lemon#lex_filenum> "18".
<http://example.org/#09824747> <http://www.monnetproject.eu/lemon#ss_type> "n".
<http://example.org/#09824747> <http://www.monnetproject.eu/lemon#gloss> " a person who is expert in the use of a bow and arrow
".
我想删除该换行符,因为它不允许以其他方式格式化文本