简体   繁体   中英

How can I make my python script wait until I tell it it to continue in the terminal?

I'm trying to make the the second print statement wait until I press enter in the command line but I keep getting an unexpected EOF error.

print "hi"
continu = input("Press Enter to continue!")
print "hi"

Here is my traceback

Traceback (most recent call last):
  File "save_cookies.py", line 2, in <module>
    continu = input("Press Enter to continue!")
  File "<string>", line 0

    ^
SyntaxError: unexpected EOF while parsing

It looks like your are mixing python2 and python3 statements.

For python2 you need to use raw_input ( PEP 3111 ):

print "hi"
raw_input("Press Enter to continue!")
print "hi"

For python3 instead, you need to adjust the syntax on the print ( PEP 3105 ):

print("hi")
input("Press Enter to continue!")
print("hi")

尝试使用raw_input()代替input()

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM