如何解决TypeError:clickButton缺少1个必需的位置参数:'number'
我正在使用Tkinter在Python中制作一个计算器,但出现错误:
user
这是我编写的代码:
<?php
// If user access item through link
if(isset($_POST["v"])) {
require "connect.php";
$v = $_POST['v'];
$sql = "SELECT * FROM videos WHERE videoID=?;";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt,$sql)) {
echo'Sql Error';
exit();
}
else {
mysqli_stmt_bind_param($stmt,"i",$v);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if (($row = mysqli_fetch_assoc($result)) && !preg_match("/[a-zA-Z]/",$v)) { ?>
<div class="img" style="background-image: url('<?php echo $row['link']; ?>');"></div>
<center><h1>Title <?php echo $row['Title']; ?> exists</h1></center>
<?php exit();
}
else { ?>
<center><h1>Title does not exist</h1></center>
<?php exit();
}
}
}
// If user clicks on item
if(isset($_POST["itemid"])) {
require "connect.php";
$itemid = $_POST['itemid'];
$sql = "SELECT * FROM videos WHERE videoID=?;";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt,$itemid);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if (($row = mysqli_fetch_assoc($result)) && !preg_match("/[a-zA-Z]/",$itemid)) { ?>
<div class="img" style="background-image: url('<?php echo $row['link']; ?>');"></div>
<center><h1>Title <?php echo $row['Title']; ?> exists</h1></center>
<?php exit();
}
else { ?>
<center><h1>Title does not exist</h1></center>
<?php exit();
}
}
}
许多小时以来,我一直在尝试纠正此错误。
P.S。我实际上不知道错误在哪一行,因为这是说错误在行1705,即使代码只有101行
解决方法
在这一行:
button_addition = Button(root,text="+",padx=40,pady=20,command=clickButton) # addition button
您正在调用无参数的clickButton
,并且在您的函数中,您需要number
。您应该像使用其他数字(上面的行)一样使用lambda
,或调用另一个函数。从您的代码的外观来看,它应该是button_add
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。