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?
JavaScript
x
19
19
1
# libraries
2
import ctypes
3
4
# get screen resolution
5
user32 = ctypes.windll.user32
6
screensize = user32.GetSystemMetrics(0), 'x', user32.GetSystemMetrics(1)
7
8
# list to store resolution and the x that is between them
9
items = []
10
11
# add resolution to list
12
for item in screensize:
13
resolution = (str(item))
14
items.append(item)
15
16
# print resolution
17
for item in items:
18
print(item, end='')
19
Its output is 1920×1080, but I need it to be like because it’s going to be among other code
JavaScript
1
3
1
print(f'''Resolution: {screen_resolution}''')
2
User: {getuser()}
3
as I am trying to remake neofetch. Unless there is a better way of getting your resolution?
Advertisement
Answer
Change screensize
definition to:
JavaScript
1
2
1
screenwidth, screenheight = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)
2
then skip all the rest of the code and replace it with:
JavaScript
1
2
1
print(f'Resolution: {screenwidth}x{screenheight}')
2