简体   繁体   中英

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

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

您编写的代码是Python 2,而不是3.以下是调用print()的方法:

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

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