我的程序按预期方式在我的桌面上运行,但不在笔记本电脑上运行,即使它安装的是相同版本的Python。Python 2.7.10在两台不同的计算机上运行代码不同
- 桌面运行Windows 7和
- 笔记本电脑运行Windows 8.1,但我升级到Windows 10,看看是否能解决这个问题。它没。
有人能告诉我我做错了什么吗?
import random
count = 0
food_list = [
"Pizza",
"Italian",
"Hamburger",
"Sandwiches",
"Salads",
"Chinese",
"Seafood",
"Mexican",
"French",
"Deli",
"Indian"
]
food_choices = []
# Header and description text
print " "
print "*" * 30
print "*" * 30
print " "
print "Food Options 1000"
print " "
print "Tell the Food Options 1000 how many options you want to select from"
print "and it will provide you with that amount of appropriate food choices."
print " "
print "*" * 30
print "*" * 30
print " "
# --- End header and description text ---
print "You have a total of %d choices from which to choose." % len(food_list)
print " "
# Receive user input and assign to a variable
optNum = int(raw_input("How many options do you want to have? "))
# Show how many choices user selected
print " "
print "Your %d choices are: " % optNum
print " "
# Run while loop until user selection integer is met
# Print food choices in the amount of user chosen number
while count != optNum:
fc = random.choice(food_list)
if fc not in food_choices:
food_choices.append(fc)
count += 1
for i in food_choices:
print i
print " "
print " "
我的成绩从桌面:
多少选择你想拥有? 8
你8个选择是:
沙拉熟食墨西哥中国比萨汉堡三明治法国
从笔记本电脑的结果:
多少选择你想拥有? 8
你8个选择是:
沙拉熟食墨西哥中国比萨墨西哥法国人法国
UPDATE:
我通过USB棒移动的文件到笔记本电脑的建议f.rodrigues 。棒上的文件正常工作,并不显示重复。在复制粘贴代码中,有不知何故在47处丢失了一行。
谢谢大家。
您是否100%确定您在两台计算机上运行完全相同的代码? – Kevin
你能解释一下代码的运行方式吗?你的预期结果是什么?发布每个平台的结果。你确定你在两个系统上都有正确的python版本吗?和所有的依赖关系安装? – onebree
是的,我通过远程协助将整个代码剪切并粘贴到笔记本电脑上的文件中,同时两台计算机都在屏幕上显示代码。 – CogentCripple