在 Python 中返回字符串中第一个非空白字符的最低索引
问题描述:
在 Python 中执行此操作的最短方法是什么?
What's the shortest way to do this in Python?
string = " xyz"
必须返回索引 = 3
答
>>> s = " xyz"
>>> len(s) - len(s.lstrip())
3