Replace each char in a multi-line string except space and \r \n, how?
- by Horace Ho
A multi-line string, e.g.
abc 123
456 def
wanted result (ordinal + 2):
cde 345
678 fgh
if I use:
text = "abc 123\n456 def"
add2=''.join(chr(ord(c)+2) for c in text)
print text
print add2
the space and \r \n will also be replaced, how can I add the exception of not including space, \r or \n in the 2nd line of code.
p.s. it's follow up to this question.