2013-11-01 84 views
-2

我需要一个pprint函数的帮助。我试图制作一个记录学生身份证号码,姓名,年龄,班级和GPA的程序。我需要使用pprint()函数来打印字典。这是我的代码到目前为止。我不知道在Python中的打印功能关于字典

student=dict() 
student['ID']= raw_input ("What is your student ID number?") 
student['name']= raw_input ("What is your name?") 
student['age']= raw_input ("How old are you?") 
student['rank']= raw_input ("What is your class rank?") 
student['gpa']= raw_input ("What is your current GPA?") 

我需要做什么?我已经尝试了多种代码的变体,但没有工作。谢谢!

+2

当声称你以前的尝试不起作用,它有助于分享这些以前的尝试等等我们可以指出你出错的地方。 – chepner

回答

3

导入pprint功能从pprint模块并通过student它:

from pprint import pprint 
pprint(student) 
+0

实际回答的问题。给予好评! – kindall

+0

非常感谢!有效! – Jack

+1

@杰克很高兴帮助,随时[接受答案](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235)如果它的工作您。 –

0

你需要import pprint和你得到后,所有的输入打印出来使用pprint.pprint(student)