Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 如何在python中逐个打开多个网页?_Python 2.7_Loops_Web - Fatal编程技术网

Python 2.7 如何在python中逐个打开多个网页?

Python 2.7 如何在python中逐个打开多个网页?,python-2.7,loops,web,Python 2.7,Loops,Web,让我们考虑以下例子: import webbrowser Cn=('Acharya Girish Chandra Bose College','AJC Bose College','Ananda Mohan College','Asutosh College','Bangabasi College','Barrackpore Rastraguru Surendranath College','Basanti Devi College') Cnw={'Acharya Girish Chandra

让我们考虑以下例子:

import webbrowser
Cn=('Acharya Girish Chandra Bose College','AJC Bose College','Ananda Mohan College','Asutosh College','Bangabasi College','Barrackpore Rastraguru Surendranath College','Basanti Devi College')

Cnw={'Acharya Girish Chandra Bose College':'http://www.agcbosecollege.org/','AJC Bose College':'http://www.ajcbosecollege.org/','Ananda Mohan College':'http://anandamohancollege.ac.in/','Asutosh College':'http://www.asutoshcollege.in/','Bangabasi College':'http://bangabasi.org/home.php','Barrackpore Rastraguru Surendranath College':'http://www.brsnc.org/','Basanti Devi College':'http://www.basantidevicollege.edu.in/'}

yy=['Y','Yes','YES','y']
nn=['N','NO','no','No','n']
i=0
while i<=range(len(Cn)):
    print 'College Name : ',Cn[i]
    a=raw_input('Do u want to visit the website ? (Y/N) :')
    if a in yy:
        webbrowser.open(Cnw[Cn[i]])
    elif a in nn:
        break
    i=i+1
导入网络浏览器
Cn=('Acharya Girish Chandra Bose学院','AJC Bose学院','Ananda Mohan学院','Asutosh学院','Bangabasi学院','Barrackbore Rastraguru Surendranath学院','Basanti Devi学院')
Cnw={'Acharya Girish Chandra Bose学院':'http://www.agcbosecollege.org/“AJC Bose学院”:http://www.ajcbosecollege.org/“阿南达莫汉学院”:http://anandamohancollege.ac.in/","华硕学院":"http://www.asutoshcollege.in/“班加巴斯学院”:http://bangabasi.org/home.php","巴拉克博拉斯特拉古鲁苏伦德拉纳学院":"http://www.brsnc.org/,“巴桑蒂·德维学院”:http://www.basantidevicollege.edu.in/'}
yy=['Y','Yes','Yes','Y']
nn=['N','NO','NO','NO','N']
i=0

虽然我不确定您为什么要使用
range()
,但只要使用
len(Cn)
就足够了,不过您应该将它改为
i
import webbrowser
Cn=('Acharya Girish Chandra Bose College','AJC Bose College','Ananda Mohan College','Asutosh College','Bangabasi College','Barrackpore Rastraguru Surendranath College','Basanti Devi College')

Cnw={'Acharya Girish Chandra Bose College':'http://www.agcbosecollege.org/','AJC Bose College':'http://www.ajcbosecollege.org/','Ananda Mohan College':'http://anandamohancollege.ac.in/','Asutosh College':'http://www.asutoshcollege.in/','Bangabasi College':'http://bangabasi.org/home.php','Barrackpore Rastraguru Surendranath College':'http://www.brsnc.org/','Basanti Devi College':'http://www.basantidevicollege.edu.in/'}

yy=['Y','Yes','YES','y']
nn=['N','NO','no','No','n']
i=0
while i<len(Cn):
    print 'College Name : ',Cn[i]
    a=raw_input('Do u want to visit the website ? (Y/N) :')
    if a in yy:
        webbrowser.open(Cnw[Cn[i]])
    #elif a in nn:
    #   break
    i=i+1
College Name :  Acharya Girish Chandra Bose College
Do u want to visit the website ? (Y/N) :n
College Name :  AJC Bose College
Do u want to visit the website ? (Y/N) :n
College Name :  Ananda Mohan College
Do u want to visit the website ? (Y/N) :n
College Name :  Asutosh College
Do u want to visit the website ? (Y/N) :n
College Name :  Bangabasi College
Do u want to visit the website ? (Y/N) :n
College Name :  Barrackpore Rastraguru Surendranath College
Do u want to visit the website ? (Y/N) :n
College Name :  Basanti Devi College
Do u want to visit the website ? (Y/N) :n
>>> ================================ RESTART ================================
>>> 
College Name :  Acharya Girish Chandra Bose College
Do u want to visit the website ? (Y/N) :y
College Name :  AJC Bose College
Do u want to visit the website ? (Y/N) :y
College Name :  Ananda Mohan College
Do u want to visit the website ? (Y/N) :y
College Name :  Asutosh College
Do u want to visit the website ? (Y/N) :y
College Name :  Bangabasi College
Do u want to visit the website ? (Y/N) :y
College Name :  Barrackpore Rastraguru Surendranath College
Do u want to visit the website ? (Y/N) :y
College Name :  Basanti Devi College
Do u want to visit the website ? (Y/N) :y
>>>