About 51 results
Open links in new tab
  1. python - How do I trim whitespace? - Stack Overflow

    Jul 26, 2009 · Is there a Python function that will trim whitespace (spaces and tabs) from a string? So that given input " \t example string\t " becomes "example string".

  2. python - How do I trim whitespace from a string? - Stack Overflow

    Apr 9, 2022 · 1 How do I remove leading and trailing whitespace from a string in Python? So below solution will remove leading and trailing whitespaces as well as intermediate whitespaces too. Like if …

  3. python - How to remove leading and trailing spaces from a string ...

    May 4, 2012 · 5 Should be noted that strip() method would trim any leading and trailing whitespace characters from the string (if there is no passed-in argument). If you want to trim space character (s), …

  4. string - How to trim characters in Python? - Stack Overflow

    Aug 13, 2011 · Very new to Python and have very simple question. I would like to trim the last 3 characters from string. What is the efficient way of doing this? Example I am going becomes I am go

  5. python - Remove all whitespace in a string - Stack Overflow

    Oct 1, 2016 · All string characters are unicode literal in Python 3; as a consequence, since str.split() splits on all white space characters, that means it splits on unicode white space characters.

  6. string - Função equivalente ao trim (função para remover espaços …

    Jan 12, 2016 · Para fazer uma função trim em python que sirva para aparar string, removendo espaços extras no início e no final, basta usar Expressão Regular indicando espaço em branco no final …

  7. python - Trim specific leading and trailing characters from a string ...

    strip (and lstrip and rstrip) is/are the python version of trim. As @pmuntima mentions, the os.path library has lots of useful path functions if we knew more about your particular application. You could …

  8. How do I remove leading whitespace in Python? - Stack Overflow

    The question doesn't address multiline strings, but here is how you would strip leading whitespace from a multiline string using python's standard library textwrap module.

  9. python - Is there a simple way to remove multiple spaces in a string ...

    Oct 10, 2009 · 65 Using regexes with "\s" and doing simple string.split ()'s will also remove other whitespace - like newlines, carriage returns, tabs. Unless this is desired, to only do multiple spaces, I …

  10. python - How do I remove a substring from the end of a string …

    926 strip doesn't mean "remove this substring". x.strip(y) treats y as a set of characters and strips any characters in that set from both ends of x. On Python 3.9 and newer you can use the removeprefix …