从文件中读出的一个汉字字符串用这个句话判断是否包含回车:pythonif'\n'inmystring:printtype(mystring)#mystring.replace('\n','')#doesnotworkmystring.replace(u'\n',u'')#doesnotworkmystring.encode("gbk")mystring.replace("\n","")#doesnotworkmystring.encode("utf-8")mystring.replace("\n","")#doesnotworkmystring.encode("ascii")mystring.replace("\n","")#UnicodeEncodeError:'ascii'codeccan'tencodecharactersinposition0-20printmystring这该如何是好?请指教!
添加回答
举报
0/150
提交
取消