我想從\n id int(10) NOT NULL
開始的行刪除\n
。我試過strip()
,rstrip()
,lstrip()
replace('\n', '')
。我不明白。我究竟做錯了什麼?Python:無法刪除 n
print(column)
print(column.__class__)
x = column.rstrip('\n')
print(x)
x = column.lstrip('\n')
print(x)
x = column.strip('\n')
print(x)
print(repr(column))
給
\n id int(10) NOT NULL
<type 'str'>
\n id int(10) NOT NULL
\n id int(10) NOT NULL
\n id int(10) NOT NULL
\n id int(10) NOT NULL
'\\n `id` int(10) NOT NULL'
Dunno。你爲什麼不展示一些實際的代碼? –
源代碼或它沒有發生! ;) – sth
..有三種可能性,'strip()','.rstrip()'和'.lstrip()',你只給出一個輸出,它不會去掉一個初始的'\ n '。你能顯示其他人的輸出嗎? (和'repr(專欄)'。) – DSM