Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试编写一个函数来检查尾随空格,但不删除空格。但我不知道该怎么做。有人可以教我吗?
谢谢你
使用str.endswith:
str.endswith
>>> 'with trailing space '.endswith(' ') True >>> 'without trailing space'.endswith(' ') False