How do I convert a normal string in another format using Python script?
For exp: a normal "String" into BOLD "String" or other format fonts!
I tried with these two modules but without success:
import pyfiglet
str_string = "Hello World"
converted_text = ""
for char in str_string:
if char.isalpha():
converted_text += chr(ord(char) + 119743)
else:
converted_text += char
with open("converted_text.txt", "a+") as file:
file.write(converted_text)
# OR
import unicodedata
def format_string(text):
converted_text = ""
for char in text:
if unicodedata.category(char) == 'L':
formatted_char = chr(ord(char) + 119743)
converted_text += formatted_char
else:
converted_text += char
return converted_text
str_string = "Hello World"
converted_text = format_string(str_string)
with open("converted_text.txt", "a+") as file:
file.write(converted_text)
What I want to achieve is to convert from a normal string "Hello World" into format to look like this " " in the output.txt
I'm using QPython 3.6.6 in Android to convert my strings.
Thanks in advance
Respect
To convert a string to lowercase, you can use the upper() method:
To convert a string to uppercase, you can use the lower() method: