# -*- coding: utf-8 -*-
#strip函数作用:清除字符型数据左右的空格。
#strip函数语法:strip
from pandas import read_csv
df = read_csv("D:/python/workspace/pythonStudy/10.csv")
newName = df['key'].str.lstrip() #去除左边的空格
newName = df['key'].str.rstrip() #去除右边的空格
newName = df['key'].str.strip() #去除两边的空格
df['key'] = newName #替换以前的列
来源:CSDN
作者:xiaoyaGrace
链接:https://blog.csdn.net/xiaoyaGrace/article/details/103777985