removing-whitespace

How to remove all white space from the beginning or end of a string?

非 Y 不嫁゛ 提交于 2019-11-26 05:23:59
问题 How can I remove all white space from the beginning and end of a string? Like so: \"hello\" returns \"hello\" \"hello \" returns \"hello\" \" hello \" returns \"hello\" \" hello world \" returns \"hello world\" 回答1: String.Trim() returns a string which equals the input string with all white-spaces trimmed from start and end: " A String ".Trim() -> "A String" String.TrimStart() returns a string with white-spaces trimmed from the start: " A String ".TrimStart() -> "A String " String.TrimEnd()

Remove all whitespace in a string in Python

这一生的挚爱 提交于 2019-11-26 00:12:52
问题 I want to eliminate all the whitespace from a string, on both ends, and in between words. I have this Python code: def my_handle(self): sentence = \' hello apple \' sentence.strip() But that only eliminates the whitespace on both sides of the string. How do I remove all whitespace? 回答1: If you want to remove leading and ending spaces, use str.strip(): sentence = ' hello apple' sentence.strip() >>> 'hello apple' If you want to remove all spaces, use str.replace(): sentence = ' hello apple'

Remove white space below image [duplicate]

孤街醉人 提交于 2019-11-25 22:29:33
问题 This question already has an answer here: Image inside div has extra space below the image 9 answers In Firefox only my video thumbnails are displaying mysterious 2-3 pixels of white space between the bottom of my image and its border (see below). I\'ve tried everything I can think of in Firebug with no luck. How can I remove this white space? 回答1: You're seeing the space for descenders (the bits that hang off the bottom of 'y' and 'p') because img is an inline element by default. This