Can also mention that your subprocess code is wrong.
When commands in a list call(recommended),then can not use
Also use
As @buran mention so may there be other way to do this,that may be just easy as copy content from clipboard.
When commands in a list call(recommended),then can not use
shell=True
.Also use
capture_output=True
to catch stdout from xsel.from subprocess import run err = run(['xsel', '--clipboard'], capture_output=True, encoding='utf-8') print(err.stdout)
Output:hello this text is from clipboard
An other library is jaraco.clipboard which can do html/image format to.As @buran mention so may there be other way to do this,that may be just easy as copy content from clipboard.