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. java mqtt

    代码: package cc.gongchang.mqtt; import java.net.URISyntaxException; import org.fusesource.hawtdispatc ...

  2. Python学习笔录

    参考:http://www.runoob.com/python3/python3-data-type.html 1. type和isinstance区别type(A()) == A, type()不会 ...

  3. c#中@标志的作用 C#通过序列化实现深表复制 细说并发编程-TPL 大数据量下DataTable To List效率对比 【转载】C#工具类:实现文件操作File的工具类 异步多线程 Async .net 多线程 Thread ThreadPool Task .Net 反射学习

    c#中@标志的作用   参考微软官方文档-特殊字符@,地址 https://docs.microsoft.com/zh-cn/dotnet/csharp/language-reference/toke ...

  4. 搭建web之 服务器鉴权失败,请确认服务器已启用密码鉴权并且账号密码正确?

    实例化时,登录过程中出现 服务器鉴权失败! 这是由于密码错误所致! 第一种情况:原始随机密码 第一种情况,你没有修改密码,则可以直接查找原始密码: 过程详见官网 使用密码登录的前提条件 密码: 若用户 ...

  5. Unity应用架构设计(6)——设计动态数据集合ObservableList

    什么是 『动态数据集合』 ?简而言之,就是当集合添加.删除项目或者重置时,能提供一种通知机制,告诉UI动态更新界面.有经验的程序员脑海里迸出的第一个词就是 ObservableCollection.没 ...

  6. eclipse工具中使用Data Source Explorer连接数据库(MySQL)

    1.进入Eclipse工具,打开Data Source Explorer.Window==>Show View==>Data Source Explorer(注:如果找不到请选择Other ...

  7. Use Dynamic Data Masking to obfuscate your sensitive data

    Data privacy is a major concern today for any organization that manages sensitive data or personally ...

  8. mysql使用自增Id为什么存储比较快

    转自:https://blog.csdn.net/bigtree_3721/article/details/73151028 InnoDB引擎表的特点 1.InnoDB引擎表是基于B+树的索引组织表( ...

  9. SQL 性能分析

    SELECT s2.dbid, s1.sql_handle, (SELECT TOP SUBSTRING(s2.text,statement_start_offset / + , ( (CASE WH ...

  10. java maven 编译文件时 有些类型文件 不存在

    在pom.xml中添加如下: <build> <resources> <resource> <directory>src/main/resource&l ...