python 判断中文字符串结尾

python环境: python 2
使用函数:endswith函数

line = "你好呀“
element = "呀”
line.endswith(element)

返回:

True

另,菜鸡发言:在python2中要非常注意中文字符串的编码问题,看是否需要使用.decode("utf-8).encode('utf-8)

发布了22 篇原创文章 · 获赞 3 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/helloworld987456/article/details/95477552