我在试着制作一个神秘的圣诞Python脚本。我有一个运行Ubuntu的虚拟机,我在里面运行脚本,没有问题。下一步,我想在PowerShell中运行它。我安装了Python,版本2.7.10(检查了vis PowerShell)。我以前在PowerShell中运行过其他脚本(甚至这个脚本的不同版本),所以我知道我已经正确地设置了这些脚本。但由于某种原因,这个不会运行。我甚至把print
语句作为import
后面的第一个实数行,但是它没有到达。我用的不是Windows内置的功能吗?在
import random
import pprint
people = ["Billy", "Joe", "Bob", "Sam", "John", "Kyle"]
chosen = {}
preventions = [["Joe", "Bob"], ["Sam", "John"]]
print "Test"
for person in people:
groupExists = False
for preventionGroup in preventions:
if person in preventionGroup:
groupExists = True
if not groupExists:
preventions.append([person])
for preventionGroup in preventions:
for person in preventionGroup:
while True:
# print "Hi"
num = random.randrange(0,6)
# print num
giftee = people[num]
if giftee not in preventionGroup and giftee not in list(chosen.values()):
chosen[person] = giftee
break
# pprint.pprint(chosen)
for key, value in chosen.iteritems():
print "Gifter: " + key
raw_input()
print "Giftee: " + value
raw_input()
它名为Secret Santa.py
,因此运行脚本的PowerShell行是
是的,我已经检查过确保我和文件在同一个目录中。在
目前没有回答
相关问题 更多 >
编程相关推荐