請問Python 2.x與3.x一個語法上的差異問題

from sys import argv

script, first, second, third = argv

print "The script is called:", script
print "Your first variable is:", first
print "Your second variable is:", second
print "Your third variable is:", third

以上是2.x的程式碼。

在3.x的阪本下,我改成如下
from sys import argv

script, first, second, third = argv

print ("The script is called:"), script
print ("Your first variable is:"), first
print ("Your second variable is:"), second
print ("Your third variable is:"), third


from sys import argv

script, first, second, third = argv

print ("The script is called:", script)
print ("Your first variable is:", first)
print ("Your second variable is:", second)
print ("Your third variable is:", third)

都會發生錯誤。請問要怎麼改才能在3.x的版本下順利執行?
2018-04-04 10:24 發佈

joshwang wrote:
from sys import...(恕刪)

from sys import argv

script = argv
first = argv
second = argv
third = argv

print ("The script is called:", script)
print ("Your first variable is:", first)
print ("Your second variable is:", second)
print ("Your third variable is:", third)



照你的程式碼,我這邊可以正常執行啊
內文搜尋
X
評分
評分
複製連結
Mobile01提醒您
您目前瀏覽的是行動版網頁
是否切換到電腦版網頁呢?