Fix isascii() method calls for python 3.6 (#4958)
* fix isascii for python3.6 * update comment with python 3.7 note Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
1 parent
2993c3fa7a
commit
c1bed601e9
2 files changed
+8
-3
No files matched your search
@@ -160,6 +160,11 @@ def is_pip():
|
||||
# Is file in a pip package?
|
||||
return 'site-packages' in Path(__file__).resolve().parts
|
||||
|
||||
def is_ascii(s=''):
|
||||
# Is string composed of all ASCII (no UTF) characters? (note str().isascii() introduced in python 3.7)
|
||||
s = str(s) # convert list, tuple, None, etc. to str
|
||||
return len(s.encode().decode('ascii', 'ignore')) == len(s)
|
||||
|
||||
|
||||
def is_chinese(s='人工智能'):
|
||||
# Is string composed of any Chinese characters?
|
||||
|
||||
Reference in new issue
Block a user