Strings
Last updated
Last updated
Escape characters, multiline strings, and raw strings (r'xyz').
Tripple quotes are handy if you have a gigantic string.
String methods return a new string instead of modifying the existing one.
Splits on white characters by default. The space is erased.
Justifies right and left. Adds padding. You can pass a 2nd argument to specify a character or string you want as a fill.
Works like rjust() and ljust() but centers the text instead of justifying it.
Sometimes we might wanna just strip off white space, from the left side, right side of both sides of the string.
Ex: if there is too much space on the left side of the string.
strip() will remove white space from either side of the string. You can also pass the strip method a character you want to remove instead of just the white space.
There is however still spam in the middle. That's just because it removed those letters up to the first character that wasn't passed to strict method. And then the same on the inside it just went down to here. So this is the string that was returned in the replace string method takes two arguments a string to
The pyperclip module has copy and paste functions that can send text to and receive text from your computer's clipboard so sending the output of your program to the clipboard will make it really easy to paste it to an email or to a word processor software or some other program.
You need to install it with pip.
pyperclip.copy() and pyperclip.paste()