从文件中读出的一个汉字字符串用这个句话判断是否包含回车: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这该如何是好?请指教!
长风秋雁
慕森王
相关分类