[Tutor] Identify whether a character is unicode control.
Cameron Simpson
cs at cskk.id.au
Fri Sep 18 18:57:03 EDT 2020
On 16Sep2020 22:49, Alexandro Gon San <AlexandroGonSan at outlook.com> wrote:
>My code:
>
>import random
>def char_is_control(char):
> #TODO
> None
>string = ''
>while len(string)<100000:
> number = random.randint(0,(256**4)-1)
> char = (number).to_bytes(4,byteorder='big').decode("utf_8",'ignore')
> if not char_is_control(char):
> string += char
>
>I need to implement the char_is_control function .
>
>I thank you very much.
While we do not do homework directly (though we will critique and make
suggestions), perhaps you should look at:
https://docs.python.org/3/library/unicodedata.html
https://docs.python.org/3/library/curses.ascii.html
and the str.isprintable() method, remembering that in Python a character
is just a string of length 1.
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Tutor
mailing list