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. 【原】Linux环境下Shell调用MySQL并实现定时任务

    对于一些周期性事务,我们可以在Linux下,使用shell脚本调用mysql数据库存储过程,并设置定时任务. 本来是要mysql数据库中创建事件任务来,定时执行存储过程,做数据传输的...使用cron ...

  2. C# System.IO.FileMode

    字段 Append 6 若存在文件,则打开该文件并查找到文件尾,或者创建一个新文件. 这需要 Append 权限. FileMode.Append 只能与 FileAccess.Write 一起使用. ...

  3. R文本挖掘之jiebaR包

    library(jiebaRD)library(jiebaR)  ##调入分词的库cutter <- worker()mydata =read.csv(file.choose(),fileEnc ...

  4. jqGrid时间转换

    colModel: [ { label: '注册时间', name: 'createDate', index: 'create_date', width: 80, formatter:function ...

  5. Atitit 管理的模式扁平化管理 金字塔 直线型管理 垂直管理 水平管理 矩阵式管理 网状式样管理 多头管理 双头管理

    Atitit 管理的模式扁平化管理  金字塔 直线型管理 垂直管理 水平管理 矩阵式管理 网状式样管理 多头管理 双头管理 1.1. 矩阵管理 1 1.2. 相关信息 矩阵的历史 1 1.3. 基于“ ...

  6. zc702-自定义AXI-IP核实验

    目的: 自定义一个IP核,通过AXI总线与ARM系统连接 环境: Win7 32bit Vivado2014.4.1 Xilinx sdk2014.4 开发板: Zc702 第一步: 新建一个自定义的 ...

  7. atom汉化

    Atom 是 Github 专门为程序员推出的一个跨平台文本编辑器. 推荐一下 Atom官方网站https://atom.io/ GitHub 以后肯定会通过官方模块把 Atom 和 GitHub 进 ...

  8. 【iCore4 双核心板_ARM】例程三十二:UART_IAP_ARM实验——更新升级STM32

    实验现象及操作说明: 1.本例程共有两个代码包,APP和IAP,IAP程序功能实现将APP程序升级至STM32中. 2.直接上电或烧写程序将执行升级的APP应用程序. BIN升级文件产生方法: 1.编 ...

  9. git学习小游戏

    学习git可以试试这个游戏:https://learngitbranching.js.org/

  10. HttpWebRequest 基础连接已经关闭: 未能为 SSL/TLS 安全通道建立信任关系

    请求对象前加入 ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate; 然后实现该方法 ...