0
how to excute python code from input and display the output?
I made a telegram bot using python.. I have two files one is bot.py and other is sever.py and it works flawlessly with normal messages... but what I want... if a user send the python code to the bot then bot should excute the code and then output the result to the user.... here is my attempt in server.py but I am getting nameError : name python is not defined input in telegram Bot : print("hello world") output in telegram Bot : hello world My attempt : https://code.sololearn.com/cjPmrilNk714/?ref=app
5 Antworten
+ 2
This is working though. Is the problem occurring when in telegram?
https://code.sololearn.com/cA15A15a1A5A
+ 1
Cyan
Jan Markus
Sorry for disturbing you guys...please help me ..
+ 1
Ratnapal Shende Yeah, I think that is because exec just execute the program and won't return the output.
See this, and try to copy that output of exec then that will be the text which will be send by your bot.
https://stackoverflow.com/questions/3906232/JUMP_LINK__&&__python__&&__JUMP_LINK-get-the-print-output-in-an-exec-statement