Problems using python with Editor in UE4

Hello, I met a problem when i using python with Editor in UE4.
I find we can use python command “unreal.EditorLevelLibrary.editor_play_simulate()” to play the editor and use python command “unreal.EditorLevelLibrary.editor_end_play()” to stop the play mode.
But I write these two commands in a file, for example “”, and then run"py", I find the editor is still in the play mode, the stop command doesn’t work.
Does anyone have suggestions?
Thank you.