+ 1
Explain Me THISSSSS..
So I was wondering in the code bits. And I saw user Creates an Output That Shows Something With Color and Background Colors without important tkinter. The Code Was; open('.png', 'w') print(''' <style> img {display: none;} body { background-color: #36454F; font-size: 10px; color: cyan; } </style> ''') I Don't know Lots About Css Or Html, But Why Are They interfereing with Python??? How Does it Even Work?And They're Should Be Something like "index.html.Why ".png" is Working?Lots Of Question, please Someone explain Me This????
3 Answers
+ 2
It is somewhat a feature here in sololearn's python code playground (not with the python language itself).
I don't know exactly how it works or the mechanisms behind (only sololearn devs know probably), but basically when you create any image file (even just empty png), the output terminal will somehow become an "html output".
And so inside the builtin print() function of python, we can use HTML tags or even CSS.
Or we could just also print some text normally, but the appearance would be quite different (higher contrast and darker background).
I use this feature too on some of my code bits since the output is quite cleaner and just to get that darker background :D
In this code, on line 89-90, I just created an empty image file and print style tag just to get that darker background:
https://sololearn.com/compiler-playground/ckSor049pI1S/?ref=app
And here is my other code where I used the same feature but now using HTML tags for formatting:
https://sololearn.com/compiler-playground/c7zdo4lBoKC1/?ref=app
+ 2
[2]
But if you're running your python code outside sololearn, on the interpreter or IDE, the output is displayed directly and literally (whatever we put on our print functions).
Though here in code playground, you can use that feature too on your python codes, to get that cooler output, background and formatting!
+ 1
I know how it works but I don't have the strength to explain all those at the moment. Maybe with time, I'll come back to this.
Sololearn python playground run in a docker environment with the root ./playground, they write to a stdout of about:blank webpage and this is because of the machine learning course for graph output