简体   繁体   English

当 class 的 object 具有 arguments 时,如何将它作为方法的参数传递给另一个 ZA2F2ED4F8EBC2CBB61ZDDC

[英]When an object of a class has arguments, how do you pass it as an argument of a method in another class

This new class(CashRegister) should accept retail object as an argument how do I go about it the class in retail has 3 argument too这个新类(CashRegister)应该接受零售 object 作为论据,我如何 go 关于它,零售中的 class 也有 3 个论据

import retail
item = retail.RetailItem(desc, unit, price)

class CashRegister:

    def purchase_item(self):
        pass

    def get_total(self):
        pass

I am not sure if you are referring to inheritance, if is that in this link: https://www.w3schools.com/python/python_inheritance.asp you can find some examples of inheritance, hope it helps我不确定您是否指的是 inheritance,如果是在此链接中: https://www.w3schools.com/python/python_inheritance.asp您可以找到一些 Z5FED3411FAF0321721Z28B2 的示例,希望对您有所帮助04

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 对象启动时如何将参数传递给类? - How to pass argument to class when object is initiated? 如何将 class object 作为参数传递给不同的 class 方法? - How can I pass a class object as an argument into a different class method? 新手,当在另一个类的方法中使用一个 class 的方法时,我是否也必须传递 self 参数 - Newbie here! When using a method of one class inside a method of another class, do I have to pass the self argument as well 如何从Python中不同类的另一个类访问方法来编辑Kivy对象? - How do you access a method from another class from a different class in Python to edit a Kivy object? 我可以将类方法和默认参数传递给另一个类方法 - Can I pass class method as and a default argument to another class method 将 Class 作为参数传递给另一个 Class - Pass a Class as an argument to another Class 如何将列表作为参数传递给方法 - How do you pass a list as an argument to a method 如何将参数从 class 传递到另一个文件 - How to pass argument from a class to another file Python,如何将函数作为参数传递给类方法 - Python, How to pass function to a class method as argument 如何将datetime对象作为参数传递给类? - How to pass datetime object as an argument into class?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM