How to run a python program in Windows 10 command prompt

∥☆過路亽.° 提交于 2020-03-15 05:46:27

问题


I am getting as such error for executing my hello world program:

"This file does not have a program associated with it for performing this action"


回答1:


1) Download the official version of Python

2) Use custom installation following the screenshots bellow.

3) Run your hello.py file directly from the command line by typing hello.py

  • Screenshots #1

  • Screenshots #2

  • Screenshots #3


  • I have this python code that I'm running on just by typing Q60471933.py
from datetime import datetime
print("\nHello World\n",datetime.now().strftime("\b%m/%d/%Y\n%H:%M:%S"))

  • Outputs:



回答2:


Try this in your command prompt:

python3 hello.py


来源:https://stackoverflow.com/questions/60471933/how-to-run-a-python-program-in-windows-10-command-prompt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!