1、strip()方法 去除字符串 开头或者结尾 的空格 str = " Hello world" str.strip() print(str.strip()) 输出: "Hello world" 2、lstrip()方法 去除字符串 开头 的空格 str = " Hello world " str.lstrip() print(str.lstrip()) 输出: