Python isnumeric()方法

栏目: 编程语言 · Python · 编程教程 · python 教程 · 发布时间: 8年前

内容简介:Python isnumeric() 方法检测字符串是否只由数字组成。这种方法是只针对unicode对象。

描述

Python isnumeric() 方法检测字符串是否只由数字组成。这种方法是只针对unicode对象。

注:定义一个字符串为Unicode,只需要在字符串前添加 'u' 前缀即可,具体可以查看本章节例子。

语法

isnumeric()方法语法:

str.isnumeric()

参数

  • 无。

返回值

如果字符串中只包含数字字符,则返回 True,否则返回 False

实例

以下实例展示了isnumeric()方法的实例:

#!/usr/bin/python


str = u"this2009";  
print str.isnumeric();

str = u"23443434";
print str.isnumeric();

以上实例输出结果如下:

False
True

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Data Structures and Algorithms in Java

Data Structures and Algorithms in Java

Michael T. Goodrich、Roberto Tamassia / Wiley / 2010-01-26 / USD 177.41

* This newest edition examines fundamental data structures by following a consistent object-oriented framework that builds intuition and analysis skills of data structures and algorithms * Presents ne......一起来看看 《Data Structures and Algorithms in Java》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

URL 编码/解码
URL 编码/解码

URL 编码/解码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试