我在一个需要5个参数的对象中有一个函数.我创建了该对象的一个实例并运行函数define(param1,2,3,4,5),它给了我一个缺少第五个参数的响应.
这是我的代码的一部分:
class KeyProperties: #Object
path = None
keytype = None
image = None
name = None
keyid = None
occupied = None
def define(self, name, path, image, keytype, keyid): #The function that is used
self.path = path
self.keytype = keytype
self.image = image
self.name = name
self.keyid = keyid
self.occupied = True
Run Code Online (Sandbox Code Playgroud)
我运行define()时的代码:
key = KeyProperties
key.define(param1,param2,param3,param4,param5)
Run Code Online (Sandbox Code Playgroud)
它给出了这个错误
TypeError:define()缺少1个必需的位置参数:'keyid'
这是创建按钮对象的简单代码行
btn = QtGui.QPushButton('Button')
Run Code Online (Sandbox Code Playgroud)
并给出这个错误
AttributeError: module 'PyQt5.QtGui' has no attribute 'QPushbutton'
Run Code Online (Sandbox Code Playgroud)
这些是我的进口
from PyQt5 import QtGui
from PyQt5 import QtCore
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
import sys
Run Code Online (Sandbox Code Playgroud)
我正在运行 Python(3.5.2)32Bit 和 PyQt5 32bit 的兼容版本我也尝试过 QtGui.QLabel 但没有运气。
我来自 Java 和 C# 背景并学习 Python。我想知道为什么这段代码在 pycharm 中给我一个错误说
Unresolved Reference 'methodA'
Run Code Online (Sandbox Code Playgroud)
用这个代码
def a():
print("hi")
def b():
a()
Run Code Online (Sandbox Code Playgroud)