私はpython 3.5を使用して同じサイトからいくつかのpdfsをダウンロードしようとしていますが、最初のpdfだけをダウンロードしてループに入ります。pdfループをダウンロード
ご協力いただければ幸いです。
import urllib.request
import urllib.error
first = int(input('First:'))
last = int(input('Last:'))
if first <= last:
response = urllib.request.urlopen("http://www.netapp.com/us/media/tr-" + str(first) +".pdf")
file = open(str(first) + ".pdf", 'wb')
file.write(response.read())
file.close()
response.close()
first = first + 1
else:
print("Completed")
「それがループになる」とはどういう意味ですか?あなたのコードにはループはありませんが、Namitの答えが示すように、ループが1つあるはずです。 –