python中input列名中带\n,如何避免print出来的转义成\n呢?
背景:选取已知excel表格的表头名
用的是google的colab,pandas
转义成\n后导致我选取不了原表的列报错"None of [Index(['P30 Average Price\n'], dtype='object')] are in the [columns]"
替换一下就行了:
x = input('').split(',')
x = [temp.replace('\\n', '\n') for temp in x]
print(x)