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

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:

主站蜘蛛池模板: 繁峙县| 册亨县| 神木县| 峨眉山市| 织金县| 太保市| 安平县| 高雄市| 兴海县| 邛崃市| 巴中市| 泰和县| 图木舒克市| 绥化市| 苏州市| 嘉义市| 梁山县| 林芝县| 江山市| 万山特区| 长乐市| 高台县| 浮山县| 如皋市| 石屏县| 株洲市| 礼泉县| 东莞市| 莫力| 大悟县| 通江县| 双江| 特克斯县| 林口县| 安阳市| 锦屏县| 高雄市| 泾阳县| 镇远县| 德江县| 岐山县|