I have made a bit of Python code that gets your resolution in Windows, how do I make it print it in an f string?
# libraries import ctypes # get screen resolution user32 = ctypes.windll.user32 screensize = user32.GetSystemMetrics(0), 'x', user32.GetSystemMetrics(1) # list to store resolution and the x that is between them items = [] # add resolution to list for item in screensize: resolution = (str(item)) items.append(item) # print resolution for item in items: print(item, end='')
Its output is 1920×1080, but I need it to be like because it’s going to be among other code
print(f'''Resolution: {screen_resolution}''') User: {getuser()}
as I am trying to remake neofetch. Unless there is a better way of getting your resolution?
Advertisement
Answer
Change screensize
definition to:
screenwidth, screenheight = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)
then skip all the rest of the code and replace it with:
print(f'Resolution: {screenwidth}x{screenheight}')