【问题标题】:Are there methods that should be downloaded into my python? [duplicate]是否有应该下载到我的 python 中的方法? [复制]
【发布时间】:2020-08-11 03:48:14
【问题描述】:

我在文本编辑器中输入了此代码,结果出现错误。那么,我是否需要为我的 Python 版本下载任何类型的文件才能使用此 isnumeric 方法?

txt = "565543"
x = txt.isnumeric()
print(x)
AttributeError: 'str' object has no attribute 'isnumeric'

【问题讨论】:

标签: python isnumeric


【解决方案1】:

isnumeric 是一个内置函数。可能是由于您的 python 版本或 python 文件,该功能无法正常工作。尝试安装python 3.6.8,它现在可以工作了,我已经试过了。

【讨论】:

    【解决方案2】:

    您很可能使用的是旧版本的 Python。

    在旧版本的 Python 中,isnumeric() 仅适用于 Unicode 对象

    尝试以这种方式运行代码:

    txt = u"565543" 
    
    x = txt.isnumeric()
    
    print(x)
    

    【讨论】:

      猜你喜欢
      • 2021-02-04
      • 2015-10-15
      • 2019-10-02
      • 2013-01-03
      • 2017-08-23
      • 2017-09-12
      • 2012-02-13
      • 2016-03-08
      • 1970-01-01
      相关资源
      最近更新 更多