我的程序按預期方式在我的桌面上運行,但不在筆記本電腦上運行,即使它安裝的是相同版本的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