![](/img/trans.png)
[英]Python - Trying to print json data from API results in a certain way
[英]Python trying to print results as menu
嗨,這就是我到目前為止
COLS= int(input("Number of Students to enter: "))
ROWS= int(input("Number of Grades per student: "))
number =[]
for c in range(COLS):
grades = []
student =(input("Enter Student ID number "))
number.append(student)
number.append(grades)
count = 1
for r in range (ROWS):
grade = (input("Enter Grade for Module "+str(count)+ ": "))
grades.append(grade)
count = count + 1
print
print (number)
print
print ('Rows and Columns')
print (student) + (grades)
一切都要count = count + 1
我很滿意。 但是我不確定如何打印結果
Rows and Columns
123 88 97 66 52
124 77 64 73 65
^^^如果輸入是,則為“菜單”
No of Students:2
No of grades: 4
student no.= 123
Grade 1 = 88
Grade 2= 97
Grade 3 = 66
Grade 4 = 52
。 菜單的下一行將是其他學生的輸入。 任何幫助,將不勝感激
您的數據結構不是最佳選擇,但是...:
for i in range(len(number)):
# if this element is an int, then following would be the list of grades.
if isinstance(number[i],str):
print(number[i],' '.join(map(str, number[i+1])))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.