Windows7中双击py文件运行程序

最近看了一本python方面的教材,洋洋洒洒写了好几页,也没将要点讲到,我现将在Window7下,双击py文件运行程序的方法总结如下:

方法

将该文件的Properties设置为如下:
Windows7中双击py文件运行程序_第1张图片
注意:别忘了在py文件中的最后加入input(“Enter the any press to exit” )这行代码。这种方法仅仅限于在Windows系统下使用,方便查看自己的运行结果。

举例

比如,我写了如下代码:

# Instructions
# Demonstraction programmer - created functions

def instructions():
    """Display game instructions"""
    print(
    """
    Welcome to the greatest intellectual challenge of all time: Tic-Tac-Toe.
    This will be a showdown between your human brain and my sillicon processor.

    You will make you move known by entering a number, 0-8. The number
    will correspond to the board position as illustrated:
                    0 | 1 | 2
                    ---------
                    3 | 4 | 5
                    ---------
                    6 | 7 | 8
    Prepare your self, human. The ultimate battle is about to begin.\n"""
    )

# main

print("Here are the instructions to the Tic-Tac-Toe:")
instructions()
input("\n\nPress the enter key to exit.")

双击该文件后,出现界面如下:
Windows7中双击py文件运行程序_第2张图片

你可能感兴趣的:(Python,python,windows,7,运行py)