开发者

python IDLE won't run my previously saved and reopened code

开发者 https://www.devze.com 2023-04-12 18:39 出处:网络
I have recently got into learning python, and when I close the IDLE and save my work. When I come back to it open idle and open my saved work and go to test it with f5 run module, module doesnt produc

I have recently got into learning python, and when I close the IDLE and save my work. When I come back to it open idle and open my saved work and go to test it with f5 run module, module doesnt produce and error codes and doesnt even print out my simple print commands. how ever if i type up a new project quickly with a few commands it works fine its just my previously saved work...

anyone have any ideas ?

my OS is windows 7 home and it may help to know I have previously installed 3.2 and 2.6

EDIT: turns out my code won't run in command through python either my code seems to be fine but will post开发者_运维知识库 it here:

import random
import time

Coin = 100
Health = 100
PCName = ()

def displayIntro():
    print "You wake, bound to the cell wall by shackles..."


exectuting this module won't do anything. You just make some imports, define some globals, and define a function. If you want to see something printed, you must call your function:

import random
import time

Coin = 100
Health = 100
PCName = ()

def displayIntro():
    print "You wake, bound to the cell wall by shackles..."

displayIntro() # when the interpreter reaches this line, a warm welcome will be printed


That code you wrote is Python 2, not 3. Here is how you should call print():

    print("You wake, bound to the cell wall by shackles...")
0

精彩评论

暂无评论...
验证码 换一张
取 消