Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.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 有人能帮我做这个项目吗?_Python - Fatal编程技术网

Python 有人能帮我做这个项目吗?

Python 有人能帮我做这个项目吗?,python,Python,每当我打印带有两个输入的students[]列表时,它都会给我一个输出[Student.Student对象位于0x03784790,Student.Student对象位于0x037D61B0] 似乎您需要实现一种方法\uuu repr\uu: class student: def __init__(self,name,sub,mark): self.name=name self.sub=sub self.mark=mark def on_kv_board(self

每当我打印带有两个输入的students[]列表时,它都会给我一个输出[Student.Student对象位于0x03784790,Student.Student对象位于0x037D61B0]


似乎您需要实现一种方法
\uuu repr\uu

    class student:
def __init__(self,name,sub,mark):
    self.name=name
    self.sub=sub
    self.mark=mark
def on_kv_board(self):
    if (self.mark>=450):
        return True
    else:`enter code here`
        return False
students=[]
num_student=int(input("Enter the number of students appeared:"))
for entries in range(0,num_student):
name=input("Student name:")
sub=input("Subject in which "+name+" got the highest mark:")
mark=int(input("Total marks obtained/500:"))
if student(name,sub,mark).on_kv_board() is True:
    a=(student(name,sub,mark))
    students.append(a)
print(students)
输出:

class student:
    def __init__(self,name,sub,mark):
        self.name=name
        self.sub=sub
        self.mark=mark
    def __repr__(self):
        return f"(Student:[{self.name}, {self.sub}, {self.mark}]) "
    def on_kv_board(self):
        if (self.mark>=450):
            return True
        else:
            return False
students=[]
num_student=int(input("Enter the number of students appeared:"))
for entries in range(0,num_student):
    name=input("Student name:")
    sub=input("Subject in which "+name+" got the highest mark:")
    mark=int(input("Total marks obtained/500:"))
if student(name,sub,mark).on_kv_board() is True:
    a=(student(name,sub,mark))
    students.append(a)

print(students)

\uuuu repr\uuuu
是可以格式化类输出的函数。

您希望输出是什么?请修改代码的格式。代码甚至没有缩进。请缩进代码,运行代码的确切问题是什么?具体点。
Enter the number of students appeared:1
Student name:123
Subject in which 123 got the highest mark:456
Total marks obtained/500:789
[(Student:[123, 456, 789]) ]