Apr-14-2019, 06:08 PM
I am using Linux Mint 19.1 and Python 3.6.
Proofreading pages of text on the web, where each row ends with a space, followed by a newline. I need to replace (strip) the space at the end of the row.
My first question is: Is it necessary to iterate through the rows one by one, or can all rows be stripped at once by using .replace() ?
I tested the following code but it doesn't work.
Proofreading pages of text on the web, where each row ends with a space, followed by a newline. I need to replace (strip) the space at the end of the row.
My first question is: Is it necessary to iterate through the rows one by one, or can all rows be stripped at once by using .replace() ?
I tested the following code but it doesn't work.
import time
keyboard.send_keys("<ctrl>+a")
time.sleep(.5)
text = clipboard.get_selection()
old = " " + "\n"
new = "\n"
text.replace(old, new)
keyboard.send_keys(text)Also tried .strip() and that doesn't work either.
Linux Mint Cinnamon 22 - Python 3.12.3 - Autokey-gtk 0.96.0 as of 2024-01-13.
