小编Gou*_*abo的帖子

Python:有什么区别 - abs和operator.abs

在python中有什么区别:

abs(a)operator.abs(a)

他们是一样的,他们的工作相似.如果它们是相同的那么为什么两个单独的函数做同样的东西?

如果其中任何一个都有某些特定功能 - 请解释一下.

python operators

3
推荐指数
1
解决办法
250
查看次数

函数“-> str”的含义

def f(ham: str, eggs: str = 'eggs') -> str:
    print("Annotations:", f.__annotations__)
    print("Arguments:", ham, eggs)
    return ham + ' and ' + eggs
Run Code Online (Sandbox Code Playgroud)

在上面的代码块中,来自https://docs.python.org/3.5/tutorial/controlflow.html#documentation-strings

我的问题是关于-> str上面的代码块中的。它有什么作用 ?

python

1
推荐指数
1
解决办法
2万
查看次数

尝试在python中制作定时器,错误在哪里?

我对 python 编程很陌生,我试图创建一个倒数计时器。我为计时器写下了以下代码,但它不起作用。你能帮忙找出错误在哪里吗?(我在这个网站上做了一些研究,发现了一些与计时器有关的问题。事实上,大部分代码都是根据另一个答案编写的,但我对其进行了一些更改,因为该代码用于时钟,我正在尝试做一个计时器。)

from tkinter import *
from tkinter import messagebox

class alarmclock():
    
    def __init__(self):
        self.alarm = Tk()
        self.l0 = Label(self.alarm, text = '----------- Alarm clock 1 -----------')
        self.l1 = Label(self.alarm, text = 'Please type in the time:')
        self.e0 = Entry(self.alarm)
        self.l2 = Label(self.alarm)
        self.b0 = Button(self.alarm, text = 'Start countdown', command = lambda: self.timer)
        self.l0.grid(row = 0, column = 0, columnspan = 2)
        self.l1.grid(row = 1, column = 0, padx = 10, pady =5)
        self.e0.grid(row = 1, column = …
Run Code Online (Sandbox Code Playgroud)

python tkinter

0
推荐指数
1
解决办法
87
查看次数

标签 统计

python ×3

operators ×1

tkinter ×1