for line in f.readlines(): print(line.strip()) # 把末尾的'\n'删掉
如果是想把末尾的‘\n’去掉,应该是用 rstrip;strip是去掉开头和结尾的(同理lstrip是去除开头的)。
Sign in to make a reply
o0stanley0o
如果是想把末尾的‘\n’去掉,应该是用 rstrip;strip是去掉开头和结尾的(同理lstrip是去除开头的)。