不明白为什么这段代码无法打开网页

时间:2019-09-19 21:41:34

标签: python

我一直在尝试使这段代码适合我自己,但我似乎做不到。有人可以帮忙吗?

这是它为我打开网页的代码。我有一个可以使用的软件,但是它太长了,无法满足职位要求。

import webbrowser

# These are the links to the Moodle pages

Agile = 'https://2019.elearning.ait.ie/course/view.php?id=1898'
Digital_Media = 'https://2019.elearning.ait.ie/course/view.php?id=1820'
Comp_Apps = 'https://2019.elearning.ait.ie/course/view.php?id=1647'
Maths = 'https://2019.elearning.ait.ie/course/view.php?id=1902'
Comms = 'https://2019.elearning.ait.ie/course/view.php?id=2244'
Web = 'https://2019.elearning.ait.ie/course/view.php?id=1790'
Software = "https://2019.elearning.ait.ie/course/view.php?id=1903"
Game = "https://2019.elearning.ait.ie/course/view.php?id=1901"

course_name = ['Digital_Media', 'Comp_Apps', 'Maths', 'Comms', 'Web',
               'Agile', 'Software', 'Game', 'end', 'all']  # list of links as strings
links = [Digital_Media, Comp_Apps, Maths, Comms,
         Web, Agile, Software, Game]  # list of links

print('Here are the courses you are doing:\n')
for x in range(len(course_name[0:8])):
    a = (course_name[x])
    print('------>', a)
print('\nShortcuts:\n------> All = open all links\n------> End = end program')

def find_link(name):
    if name == course_name:
        print('Here Is Your Link: {}'.format(links[course_name.find(name)]))
        webbrowser.open(links[course_name.find(name)])


while True:
     try:
         course_name=input('\nEnter Course:')
     except not course_name:
         print('--->Not a course\n')
     else:
         find_link(course_name)

0 个答案:

没有答案