Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't .isascii() work on google colab?

I am working on Windows 10 and Pycharm IDE. Is there a reason that .isascii() does not work on google colab? When I try the snippet of code on google colab I'm getting:

AttributeError: 'str' object has no attribute 'isascii'

If I try the same code on my IDE I'm getting True.

thisstr = "Hoho"
k = thisstr.isascii()
print(k)
like image 377
JBB Avatar asked Dec 17 '22 12:12

JBB


1 Answers

The python version in Google Colab is 3.6 while isascii method is introduced in Python 3.7. Quoting from What's new in Python 3.7:

str, bytes, and bytearray gained support for the new isascii() method, which can be used to test if a string or bytes contain only the ASCII characters.

like image 131
Asocia Avatar answered Dec 31 '22 15:12

Asocia