Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

error in python d not defined.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In Python 2.x, input() expects something which is a Python expression, which means that if you type d it interprets that as a variable named d. If you typed "d", then it would be fine.

What you probably actually want for 2.x is raw_input(), which returns the entered value as a raw string instead of evaluating it.

Since you're getting this behavior, it looks like you're using a 2.x version of the Python interpreter - instead, I'd go to www.python.org and download a Python 3.x interpreter so that it will match up with the book you're using.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...