Windows7中双击py文件运行程序

本文详细介绍了在Windows系统下通过设置文件属性双击运行.py文件的方法,并提供了示例代码,确保用户能够轻松地查看并调试自己的程序。

最近看了一本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.")

双击该文件后,出现界面如下:
这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值