相关疑难解决方法(0)

Python:如何检查unicode字符串是否包含一个cased字符?

我正在做一个过滤器,其中我检查unicode(utf-8编码)字符串是否不包含大写字符(在所有语言中).如果字符串根本不包含任何套接字符,那对我来说没问题.

例如:'你好!' 不会通过过滤器,但"!" 应该通过过滤器,因为"!" 不是一个套装的角色.

我打算使用islower()方法,但在上面的例子中,"!".islower()将返回False.

根据Python Docs,"如果unicode字符串的套接字符全部为小写且字符串包含至少一个套接字符,则python unicode方法islower()返回True,否则返回False."

由于当字符串不包含任何套接字符时,该方法也返回False,即."!",我想检查字符串是否包含任何套接字符.

像这样......

string = unicode("!@#$%^", 'utf-8')

#check first if it contains cased characters
if not contains_cased(string):
     return True

return string.islower():
Run Code Online (Sandbox Code Playgroud)

有关contains_cased()函数的任何建议吗?

或者可能采用不同的实施方法?

谢谢!

python unicode lowercase uppercase

8
推荐指数
2
解决办法
4966
查看次数

Python 2.5.2是否遵循Unicode()和upper()?

我正在制作Google AppEngine应用程序.Python 2.5.2运行时环境是否遵循Unicode标准?(例如,unicode对象上的lower()和upper()方法.)

python unicode case-sensitive

2
推荐指数
1
解决办法
2002
查看次数

标签 统计

python ×2

unicode ×2

case-sensitive ×1

lowercase ×1

uppercase ×1