cccI有一個python腳本,這讓我瘋狂。這是有問題的代碼... if語句代碼沒有運行,有人可以說明爲什麼?:python有條件的問題(2.7)
print("refresh_type is: " + refresh_type)
if (refresh_type == "update"):
print("hello world")
cmd = 'sudo svn %s --username %s --password %s %s' % ('up', un, pw, working_path)
print("command is: " + str(cmd))
elif(refresh_type == 'checkout' or refresh_type == 'co'):
cmd = 'sudo svn %s --username %s --password %s %s %s' % (refreshType, un, pw, rc_service_url, working_path)
print('username = ' + credentials['un'])
print('password = ' + credentials['pw'])
print("working path = " + working_path)
這裏是打印報表的輸出:
refresh_type is: 'update'
username = 'cccc'
password = 'vvvvv'
working path = '/home/ubuntu/workingcopy/rc_service'
你可以在括號更容易出現了很多;在python 2.7中'print'不是*函數。你的意思是'if語句沒有運行'? –
到目前爲止,我對python的一個抱怨是缺乏劃分行爲的東西。我喜歡把括號放在那裏,因爲它使我立刻明白我在做什麼。是的,你不需要他們,但這對我來說就像在周圍畫一個盒子。我喜歡。我會繼續這樣做。我不會遇到像其他語言中的分號一樣的結尾字符,也不會使用大括號來表示函數。我也喜歡他們。 :) – BillR