嗨,我不能让它正常工作(字符串索引)

时间:2019-05-08 17:35:04

标签: python

我一直收到这样的错误消息:字符串索引必须是整数。 错误消息= print(“ Name:”,user_ID ['name']) TypeError:字符串索引必须为整数

试图通过将int(user_ID ['name'])设置为int

def main(user_ID):
    user = canvas_requests.get_user(user_ID)
    print_user_info(user_ID)
    courses = canvas_requests.get_courses(user_ID)
    available_courses = filter_available_courses(course_dict)
    print_courses(course_list)
    course_IDS = get_course_ids(course_list)
    course_ID = choose_course(sub_list)
    sub_dict = canvas_requests.get_submissions(user_ID, sub_list)
    summarize_points(sub_dict)
    summarize_groups(sub_dict)
    plot_scores(sub_dict)
    plot_graph_trends(sub_dict)

def print_user_info(user_ID):
    print("Name:", user_ID['name'])
    print("Primary Email:", user_ID['primary_email'])
    print("Title:", user_ID['title'])
    print("Bio:", user_ID['bio'])

应该只打印个人的姓名

0 个答案:

没有答案