官术网_书友最值得收藏!

Using the strip method

Let's start off by analyzing the strip method. Imagine that the input you get from the user or from the database is poorly formatted and contains white spaces before and after the value. To clean the data up, we can use the strip method. Consider this example:

str = "  The quick brown fox jumped over the quick dog  " 
p str.strip

When you run this code, the output is just the sentence without the white spaces before and after the words:

主站蜘蛛池模板: 年辖:市辖区| 前郭尔| 汶川县| 轮台县| 平山县| 新河县| 澜沧| 达拉特旗| 广平县| 读书| 蒙山县| 余干县| 定安县| 班玛县| 富宁县| 固安县| 林甸县| 五大连池市| 景泰县| 于田县| 龙胜| 乌拉特后旗| 遵化市| 延庆县| 科技| 崇仁县| 兴海县| 黎平县| 察隅县| 德江县| 综艺| 探索| 河北省| 临西县| 普兰县| 绍兴县| 聊城市| 麟游县| 兴业县| 河津市| 辽阳市|