問題是:一個小小的字母,每邊都有三個大型保鏢包圍。 我寫了這段代碼並得到了答案。我認爲這是正確的,但它不起作用。有誰能夠幫助我?我的回答:KWGtIDC蟒蛇挑戰3級
import urllib, sys, string
from string import maketrans
bbb = 0
f = urllib.urlopen("http://www.pythonchallenge.com/pc/def/equality.html")
while 1:
buf = f.read(200000)
if not len(buf):
break
for x in range(len(buf)):
if buf[x] in string.ascii_lowercase:
if buf[x+1] in string.ascii_uppercase:
if buf[x-1] in string.ascii_uppercase:
if buf[x+2] in string.ascii_uppercase:
if buf[x-2] in string.ascii_uppercase:
if buf[x+3] in string.ascii_uppercase:
if buf[x-3] in string.ascii_uppercase:
if buf[x+4] in string.ascii_lowercase:
if buf[x-4] in string.ascii_lowercase:
bbb = x
sys.stdout.write(buf)
print(buf[bbb-3:bbb+4])