python 判断字符串中是否只有中文字符 学习了:https://segmentfault.com/q/1010000007898150 def is_all_zh(s): for c in s: if not ('\u4e00' <= c <= '\u9fa5'): return False return True
下面是某个字符串是否为IP地址import re def isIP(str): p = re.compile('^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$') if p.match(str): return True else: return FalsemyStr = "10.69.36.95"if isIP(myStr): print(myStr,"it is a IP!"