如何在python上检查跟踪空格?

如何在python上检查跟踪空格?,python,string,whitespace,syntax-checking,Python,String,Whitespace,Syntax Checking,我试图编写一个函数来检查trail空格,但不删除空格。但我不知道该怎么做。有人能教我吗 感谢您使用: 使用: 使用: 使用: >>> 'with trailing space '.endswith(' ') True >>> 'without trailing space'.endswith(' ') False

我试图编写一个函数来检查trail空格,但不删除空格。但我不知道该怎么做。有人能教我吗

感谢您使用:

使用:

使用:

使用:

>>> 'with trailing space  '.endswith(' ')
True
>>> 'without trailing space'.endswith(' ')
False