我正在Windows 10和Pycharm IDE上工作。有.isascii()
没有在Google colab上不起作用的原因?当我在google colab上尝试代码段时,我得到:
AttributeError: 'str' object has no attribute 'isascii'
如果我在IDE上尝试相同的代码,我会得到True
。
thisstr = "Hoho"
k = thisstr.isascii()
print(k)
Google Colab中的python版本是3.6,而isascii
Python 3.7中引入了方法。引用Python 3.7的新增功能:
str
,bytes
和bytearray
获得了对新isascii()方法的支持,该方法可用于测试字符串或字节是否仅包含ASCII字符。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句