I am working on a project that uses Python to download and install applications. The repos where the application info is stored has a line in json
that states if the user is verified, this is then converted to a True
or False
variable. After downloading the info on the user it prints the info on screen using the rich.print
function, in the rich
module. I want to be able to print a verified symbol, like on Twitter, how can I do this?
manifest.json
{
"Name": "Test package",
"License": "Public Domain",
"Developer": "Hearth OS",
"DeveloperWWW": "https://hearth-os.github.io/",
"Description": "Hello World package.",
"Verified": "True",
"Version": "0.1",
"AppID": "com.hearth-os.test"
}
main.py (Lines 72-90)
# Write and open manifest.json
open("manifest.json", 'wb').write(r.content)
jsonFile = open("manifest.json", "r")
manifest = json.load(jsonFile)
# Read `manifest`
name = manifest['Name']
license = manifest['License']
developer = manifest['Developer']
www = manifest['DeveloperWWW']
description = manifest['Description']
verified = manifest['Verified']
version = manifest['Version']
id = manifest['AppID']
# Print `manifest`
rich.print('Package: ' + name)
rich.print('Developer: [link=' + www + ']' + developer + '[/link]')
rich.print('License: ' + license)
If your "verified symbol" is a unicode character you can just print it:
if verified:
print("✅")
If in python2 you might need to specify an encoding at the top of your file or you will get an error. UTF-8 is a common choice (and the default in python3)
# -*- coding: utf-8 -*-
You can also avoid embedding unicode literal characters in your code by using the unicode escape sequence (you need to look up the code for your symbol of choice):
print("\u2705")