无法运行Python代码

无法运行Python代码,python,Python,我已经在目录c:\users\rshukla\desktop\Python\python35 我下载了一个简单的Python代码,它保存在Atom.io中,也保存在同一个文件夹c:\users\rshukla\desktop\Python\happy\u hour.py 我正试图让它通过Powershell运行 import random bars = ["Shoolbred's", "The Wren", "The Scratcher", "ACME", "B

我已经在目录
c:\users\rshukla\desktop\Python\python35

我下载了一个简单的Python代码,它保存在Atom.io中,也保存在同一个文件夹
c:\users\rshukla\desktop\Python\happy\u hour.py
我正试图让它通过Powershell运行

import random

bars = ["Shoolbred's",
    "The Wren",
    "The Scratcher",
    "ACME",
    "Blind Barber"]

people = ["Mattan",
      "Chris",
      "Pooje",
      "that person you forgot to text back",
      "Kanye West",
      "Samuel L. Jackson"]

random_bar = random.choice(bars)
random_person_1 = random.choice(people)
random_person_2 = ramndon.choice(people)

print(f"How about you go to {random_bar} with {random_person_1} and {random_person_2}")
当我尝试在Powershell中运行此程序时,我得到以下输出-我做错了什么

PS C:\Users\rshukla\desktop\python> python happy_hour.py
python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ python happy_hour.py
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (python:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

您必须将python放在路径中。看到这个了吗

但我认为这种格式字符串在Python3.6中是新的,在Python3.5中是不可用的

使用函数 对于python3.5:

print({two}{plus}{two}=4'.格式(two=2,plus='4'))
或其他字符串格式化方法:

print(“%d%s%d=4”%(2,“+”,2))
打印(“%(两个)d%(加上)s%(两个)d=4”%{“两个”:2,“加上”:“+”})
尝试执行以下操作:
c:\users\rshukla\desktop\python35 c:\users\rshukla\desktop\python\happy\u hour.py

如果不想键入python可执行文件(python35)的完整路径,请将此路径
c:\users\rshukla\desktop\python
添加到PS shell中的path变量中

PATH变量是powershell搜索您试图执行任何CMD行实用程序的可执行文件的位置,目前它(powershell)无法找到python35,因此您可以提供python35 exe的整个路径,或者将目录添加到PATH变量中


ps.忽略打字错误,通过mobile编写

您是否设置了环境变量,以便windows知道在哪里可以找到Python?检查这里,尽管这是不相关的,因为脚本从未被加载。