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

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:

主站蜘蛛池模板: 称多县| 洪泽县| 武汉市| 来凤县| 乌拉特后旗| 河东区| 宿松县| 寿光市| 黑水县| 华池县| 白银市| 和龙市| 新巴尔虎左旗| 德令哈市| 荔波县| 康定县| 青阳县| 尚义县| 鄢陵县| 定安县| 宜宾市| 铅山县| 汽车| 乐都县| 安庆市| 忻城县| 遂川县| 涞水县| 瓮安县| 布尔津县| 阆中市| 和硕县| 兴化市| 邯郸市| 南华县| 水富县| 思南县| 万全县| 洪湖市| 勃利县| 绥江县|