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

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:

主站蜘蛛池模板: 泾阳县| 大邑县| 日照市| 华阴市| 墨竹工卡县| 三江| 宜章县| 迁安市| 合山市| 顺平县| 佛冈县| 密云县| 枝江市| 宕昌县| 彭水| 葵青区| 通河县| 当雄县| 济阳县| 武山县| 达拉特旗| 上高县| 正阳县| 荆州市| 信阳市| 榕江县| 石泉县| 城口县| 当涂县| 七台河市| 调兵山市| 锡林郭勒盟| 浦江县| 来宾市| 黄石市| 河津市| 沙湾县| 广元市| 龙岩市| 怀来县| 北海市|