Python 3.2有Bug
两个例子:
import random
guessesTaken = 0
print(‘Hello! What is your name?’)
myName = input()
number = random.randint(1, 20)
print (‘Well, ‘ + myName + ‘, I am thinking of a number between 1 and 20.’)
while guessesTaken < 6:
print ('Take a guess.') # There are four spaces in front of print.
guess = input()
guess = int(guess)
guessesTaken = guessesTaken + 1
if guess < number:
print ('Your guess is too low.') # There are eight spaces in front of print.
if guess > number:
print (‘Your guess is too high.’)
if guess == number:
break
if guess == number:
guessesTaken = str(guessesTaken)
print (‘Good job, ‘ + myName + ‘! You guessed my number in ‘ + guessesTaken + ‘ guesses!’)
if guess != number:
number = str(number)
print (‘Nope. The number I was thinking of was ‘ + number)
input()
在IDLE下面执行正常,双击执行,print打印函数会少打印前面的数据。
import time
print(time.ctime())
while (True):
cmd = input(‘Enter: ‘)
if cmd == ‘A’ or cmd == ‘a’:
print(‘Choose A!’)
elif cmd == ‘B’ or cmd == ‘b’:
print(‘Choose B!’)
else:
print(‘Exit!’)
break
input()
同样,在IDLE下面执行正常,在双击执行情况下,无论怎么样,都只执行else选型。