I'm creating a script and have sucsessfully called on a second one, however, when the second one completes. The program just crashes - is it possible so after the import script section as completed, it will then continue back on the main script.
EG
My main one, which is titled Login_MainMenu.py as this script in:
if command == ('caesar'):
import os
os.system('caesarCipher.py')
time.sleep(2)
print("Your task is now completed")
sys.exit()
I'm assuming I'd have to put something at the end of caesarCipher.py, which for now is:
mode = getMode()
message = getMessage()
key = getKey()
print("\nYour translated text is: ")
print(getTranslatedMessage(mode, message, key))
Anyone got any ideas on how to do it?
Thank you.
There's nothing you have to do to return back. If it's crashing, you have a bug somewhere, but since you didn't tell us what the error message was, there's no way to help you.
However, you should not be running your other script via os.system
. Import it and call its functions directly.
import caesarCipher
caesarCipher.get_translated_message()
assuming you've put the code into a function called get_translated_message
, anyway.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.