python下的isdigit函数:

   isdigit() 方法检测字符串是否只由数字组成。

语法

isdigit()方法语法:  str.isdigit()

示例代码如下:

结果:

  

我想说的重点在于:

  这里面会有一个坑,那就是。Number = input("1234:")即从控制台上获取一串值

那么就有

python input() 相等于 eval(raw_input(prompt)) ,用来获取控制台的输入。

raw_input() 将所有输入作为字符串看待,返回字符串类型。而 input() 在对待纯数字输入时具有自己的特性,它返回所输入的数字的类型( int, float )。

当输入全数字字符串时,这时候在使用Number.isdigit()就会报错(AttributeError: 'int' object has no attribute 'isdigit'),已经是int类型的值,在使用该函数,肯定会报错。

那么最好是选用raw_input()函数,作为动态输入方法,负责就会掉入坑。

AttributeError: 'int' object has no attribute 'isdigit'(python下的isdigit函数)的更多相关文章

  1. AttributeError: 'int' object has no attribute 'log'

    我们有时候在对组数进行操作时候,偶尔会出现这个问题. 比如: #coding:utf- import pandas as pd import numpy as np if __name__ == '_ ...

  2. 解决代理池的问题AttributeError: 'int' object has no attribute 'items'

    https://blog.csdn.net/mygodit/article/details/86689127

  3. AttributeError: 'int' object has no attribute 'upper'

    因为安装的openpyxl版本是2.3.4,而代码是: sheet.cell(rownumber, 1).value = data['id']参数不对,应该是: sheet.cell(None, ro ...

  4. [已解决]报错:报错AttributeError: 'int' object has no attribute 'upper'

    原因:openpyxl版本低,需升级 pip install --upgrade openpyxl

  5. AttributeError: 'str' object has no attribute 'lowerr' Python常见错误

    方法名拼写错误 检查方法名拼写,如有错误改正即可 特别注意m和n

  6. AttributeError: 'module' object has no attribute 'enableTrace'

    Traceback (most recent call last): File "Long-lived-connection.py", line 29, in <module ...

  7. Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法

    最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...

  8. python提示AttributeError: 'NoneType' object has no attribute 'append'【转发】

    在写python脚本时遇到AttributeError: 'NoneType' object has no attribute 'append' a=[] b=[1,2,3,4] a = a.appe ...

  9. Python使用suds调用webservice报错解决方法:AttributeError: 'Document' object has no attribute 'set'

    使用python的suds包调用webservice服务接口,报错:AttributeError: 'Document' object has no attribute 'set' 调用服务接口代码: ...

随机推荐

  1. Django根据现有数据库建立/更新model

    Django引入外部数据库还是比较方便的,步骤如下: 创建一个项目,修改seting文件,在setting里面设置你要连接的数据库类型和连接名称,地址之类,和创建新项目的时候一致 运行下面代码可以自动 ...

  2. chrome浏览器美化插件:让您的浏览器页面冒水泡, 游小鱼儿

    下载插件和效果图 这是一个让你的浏览器冒泡泡的插件, 浏览网页的时候仿佛置身于海底世界: 插件下载地址:http://files.cnblogs.com/files/diligenceday/chro ...

  3. Jacoco统计web接口/功能测试的代码覆盖率【转】

    原文:https://www.jianshu.com/p/d2fd02d4164b 一.代码覆盖率 通常我们在做单元测试的时候会接触到代码覆盖率的概念,通过在单元测试的过程中收集代码覆盖率去判断测试用 ...

  4. 微信小程序--相关资料

    微信小程序Demo https://github.com/zce/weapp­-demojustjavac/awesome­wechat­weapp: 微信小程序开发资源汇总 https://gith ...

  5. 【20171123】【GITC精华演讲】贝业新兄弟李济宏:如何做到企业信息化建设的加减乘除

    导读 11月23日智慧物流论坛上,贝业新兄弟李济宏分享了<如何做到企业信息化建设的加减乘除>演讲,介绍了如何更好的构建企业信息化系统. 30秒get演讲干货 为什么用户总说系统难用?为什么 ...

  6. Spark 官方博文专区(目录)

    关于转载一些 Spark 官方的文档以及 DataBricks 公司博文,本系列基本是中英双语,主要是为了提高自己的英语水平. 文章分类 spark databricks A Tale of Thre ...

  7. Python生成随机字符串

    利用Python生成随机域名等随机字符串. #!/usr/bin/env python# -*- coding: utf-8 -*- from random import randrange, cho ...

  8. 记一次wordpress安装过程中遇到的问题及解决办法

    Q:无法建立目录wp-content/uploads/2017/03.有没有上级目录的写权限?A:执行chmod 777 wp-content/ 提升目录权限 Q:安装主题或安装插件的时候,用到FTP ...

  9. Android 引用外部字体

    在Android中,加载外部字体是非常容易的! 步骤如下: 1. 创建新的Android工程: 2. 在工程下的assets文件夹下新建名字为fonts的文件夹(名字可以任意选取),把所有的外部字体文 ...

  10. Linux set、env、declare、export显示shell变量的区别

    目录 Linux中 set.env.declare.export显示shell变量的区别 1. shell局部变量 2. 用户的环境变量 显示shell变量 declare 命令 export 命令 ...