How to import html into python file | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to import html into python file

I have developed a game in html. And i want to import html into python and get the out is it possible. If yes using which library.

21st Feb 2021, 10:28 AM
Pranay Sehgal
Pranay Sehgal - avatar
7 Answers
+ 3
well, it's not really running html inside of python... the trick here only works in python sololearn code playground, wich allow outputing html code as soon as you create an image file (output is then turned to html to be able to append the image to the log)... that's why there is the statement: os.system("touch file.png")
21st Feb 2021, 10:50 AM
visph
visph - avatar
+ 2
yes.
4th Mar 2022, 3:43 AM
visph
visph - avatar
21st Feb 2021, 10:45 AM
Pranay Sehgal
Pranay Sehgal - avatar
+ 1
Hey visph Can you tell me more about this? I am interested in knowing why output is getting converted to html only(not other file format) when empty image file is created? Also, what is the log that you mentioned in the comments?
3rd Mar 2022, 12:56 PM
Sandeep
Sandeep - avatar
+ 1
visph Let me summarise what I have understood: How it works? Whenever we type any code in sololearn playground, it will first execute it, and store the result in a file called log. Before ml course, this log file used to display results normally but with the introduction of ml course they need to add the support for showing images. Therefore, they added this and if an image is created then they convert all the output to html(instead of text) and show it in the console and since they are showing the html output if there is any valid html code inside the script we created, it will also run that and show it to us! Am i right?
4th Mar 2022, 3:39 AM
Sandeep
Sandeep - avatar
0
no, you cannot "run" html code inside of python...
21st Feb 2021, 10:42 AM
visph
visph - avatar
0
that's a feature from sololearn: they introduced it for lessons about machine learning and so on... the "log" I talked about is the script output (done on sololearn servers, and then returned to be displayed)... Programing languages initialy use basic (raw text) output, and is unable to display graphics, or even colors/animation... so the workaround was to use the html-based output to enhance the capacities ;)
3rd Mar 2022, 9:25 PM
visph
visph - avatar