Python isalnum()方法

Python 教程 · 2019-02-02 11:57:17

描述

Python isalnum() 方法检测字符串是否由字母和数字组成。

语法

isalnum()方法语法:

str.isalnum()

参数

  • 无。

返回值

如果 string 至少有一个字符并且所有字符都是字母或数字则返回 True,否则返回 False

实例

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

实例(Python 2.0+)

#!/usr/bin/python # -*- coding: UTF-8 -*- str = "this2009"; # 字符中没有空格 print str.isalnum(); str = "this is string example....wow!!!"; print str.isalnum();

以上实例输出结果如下:

True
False

点击查看所有 Python 教程 文章: https://codercto.com/courses/l/8.html

查看所有标签

The Web Application Hacker's Handbook

The Web Application Hacker's Handbook

Dafydd Stuttard、Marcus Pinto / Wiley / 2011-9-27 / USD 50.00

The highly successful security book returns with a new edition, completely updated Web applications are the front door to most organizations, exposing them to attacks that may disclose personal infor......一起来看看 《The Web Application Hacker's Handbook》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

在线进制转换器
在线进制转换器

各进制数互转换器

SHA 加密
SHA 加密

SHA 加密工具