python_examples/rand_char.py

10 lines
264 B
Python
Raw Normal View History

2023-08-23 11:11:51 -04:00
import random
characters = ''
try:
characters = ''.join([chr(random.choice([i for i in range(0x0, 0xD7FF + 1) if i < 0xD800 or i > 0xDFFF])) for _ in range(5000)])
except UnicodeEncodeError as e:
print(f"Error encoding character: {e}")
print(characters)