내 파이썬 스크립트 "동안"
app = "google facebook yahoo"
prec = 0
test = 0
while test < 4 :
print "The test is test%d" % (test)
while prec < 4 :
prec = prec + 1
for i in app.split():
print "The word is " + (i) + " precedence %d" % (prec)
지금
실제 출력 :
그것의 연속 인쇄 다음중첩 루프
The test is test0
The test is test0
The test is test0
The test is test0
The test is test0
The test is test0
예상 출력 :
The test1 is
The word is google precedence 1
The word is facebook precedence 2
The word is yahoo precedence 3
The test2 is
The word is google precedence 1
The word is facebook precedence 2
The word is yahoo precedence 3
The test3 is
The word is google precedence 1
The word is facebook precedence 2
The word is yahoo precedence 3
The test4 is
The word is google precedence 1
The word is facebook precedence 2
The word is yahoo precedence 3
g 이 결과물을 얻는 방법에 관해 나에게 도움이된다. 미리 감사드립니다.
또한 내부 루프에서'enumerate '를 사용하는 방법을 보여 줄 수 있습니다. – georg