次のようなリストがあります。
website = ['http://freshtutorial.com/install-xamp-ubuntu/', 'http://linuxg.net/how-to-install-xampp-on-ubuntu-13-04-12-10-12-04/', 'http://ubuntuforums.org/showthread.php?t=2149654', 'http://andyhat.co.uk/2012/07/installing-xampp-32bit-ubuntu-11-10-12-04/', 'http://askubuntu.com/questions/303068/error-with-tar-command-cannot-install-xampp-1-8-1-on-ubuntu-13-04', 'http://askubuntu.com/questions/73541/how-to-install-xampp']
次のリストに特定の URL が含まれているかどうかを検索します。
URL は次の形式になります。url = 'http://freshtutorial.com'
ウェブサイトはリストの最初の要素です。したがって、 0 ではなく1 を出力したいと思います。
その URL を持つ Web サイトがない場合は、再び実行して動的にリストを生成し、Web サイトを再度検索するように、すべてをループに入れたいと考えています。
私は今までこれを行ってきました:
for i in website:
if url in website:
print "True"
位置を印刷してすべてをループでラップすることができないようです。また、構文を使用する方が良いですregex
か。if this in that
ありがとう