您的位置:首页 > 编程语言 > Python开发

Windows7中双击py文件运行程序

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

方法

将该文件的Properties设置为如下:



注意:别忘了在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.")


双击该文件后,出现界面如下:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python windows 7 运行py