RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-307944

vladionair's questions

Martin Hope
vladionair
Asked: 2022-01-05 18:09:08 +0000 UTC

输入字符串处理导致的内存错误[关闭]

  • -1
关闭 这个问题是题外话。目前不接受回复。

问题已结束,因为在俄语的 Stack Overflow 上,习惯上只用俄语提问。请将您的问题翻译成俄语或使用英语的 Stack Overflow。

1 年前关闭。

改进问题

我在尝试运行我的代码时遇到了这个错误。如果你知道我如何改变它,请告诉我!两三步...

Failed test #2 of 11. Runtime error

Error:
Traceback (most recent call last):
  File "jailed_code", line 30, in <module>
    for j in num: 
  File "jailed_code", line 5, in aP
    a = [1]*n
MemoryError

def aP(n):
a = [1]*n
y = -1
v = n
while v > 0:
    v -= 1
    x = a[v] + 1
    while y >= 2 * x:
        a[v] = x
        y -= x
        v += 1
    w = v + 1
    while x <= y:
        a[v] = x
        a[w] = y
        yield a[:w + 1]
        x += 1
        y -= 1
    a[v] = x + y
    y = a[v] - 1
    yield a[:w]
    
lst = []
res = []
input = input().split(' ')
for i in input:
    num = aP(int(i))
    for j in num: 
        if len(j) == 3:
            lst.append(j)
    res.append(len(lst))
    lst = []
res = str(res).replace(',', '')
print(res[1:-1])
python-3.x
  • 1 个回答
  • 10 Views
Martin Hope
vladionair
Asked: 2020-01-13 00:01:12 +0000 UTC

通过更改类属性调用函数

  • 1

任务是用一个函数捕获另一个函数更改类属性的工作结果。我该怎么做,也许使用__getattribute__?

python
  • 1 个回答
  • 10 Views
Martin Hope
vladionair
Asked: 2020-06-23 03:49:09 +0000 UTC

将作业转换为类型链

  • 1

这样的问题......根据作业,我需要将此代码转换为以下类型链:int -> float -> float,但我不能这样做(我会很高兴任何澄清!

let vat n x = if 0.0 <= n && n <= 100.0 then (n / 100.0) * x else 0.0
let n_perc = vat 1.0
printfn "%f" (n_perc 100.0)
f#
  • 1 个回答
  • 10 Views
Martin Hope
vladionair
Asked: 2020-05-15 18:59:28 +0000 UTC

遍历树时使用递归

  • 1

问题是这样的:如果我在递归函数调用之前指定返回:return find(node, counter)- 它过早终止,跳过树的第一个分支。如果我没有指定:find(node, counter)- 遍历所有节点,但不返回计数器。如何遍历整棵树?

def Count(self):
    if not self.Root:
        return 0
    tree = self.Root
    counter = 1
    def find(tree, counter):
        for node in tree.Children:
            counter += 1
            if node.Children:
                return find(node, counter) # this place
        return counter
    count = find(tree, counter)
    return count
python
  • 2 个回答
  • 10 Views
Martin Hope
vladionair
Asked: 2020-11-17 01:13:56 +0000 UTC

在 python 类中使用装饰器

  • 0

我需要你的帮助)在第一个示例中,当在函数中使用装饰器时,我随后可以单独使用装饰函数(calc),但在第二个示例中,我不能:/如何做到这一点???!

示例 1:

def prog(calc):
    def print_res():
        calc()
        print('print result')
    return print_res
def calc():
    print('calculate')
x = prog(calc)
x()
print()
calc()

结论:

calculate
print result

calculate

示例 2:

class A:
    def __init__(self, l = 0):
        self.l = l
    def account(calc):
        def print_res(self, n, m):
            calc(self, n, m)
            print('result =', self.l)
        return print_res
    @account
    def calc(self, n, m):
        self.l = n + m
test = A()
test.calc(1, 1)

结论:

result = 2
python-3.x
  • 3 个回答
  • 10 Views
Martin Hope
vladionair
Asked: 2020-09-29 19:56:22 +0000 UTC

第 15 行的 AttributeError:“str”对象没有属性“play”

  • -1
name = input()
meth = input()
class Player:
    def __init__(self, name):
        self.name = name
    def play(self, name):
        return print(name, 'is playing')
    def ff(self, name):
        return print(name, 'is fast forward')
    def rew(self, name):
        return print(name, 'is rewind')
    def stop(self, name):
        return print(name, 'is stop')
    if meth == 'play':
        name.play()
    elif meth == 'ff':
        name.ff()
    elif meth == 'rew':
        name.rew()
    elif meth == 'stop':
        name.stop()
python
  • 1 个回答
  • 10 Views
Martin Hope
vladionair
Asked: 2020-08-31 19:27:20 +0000 UTC

从字符串/列表中提取大于 9 的数字

  • 1

需要从字符串/列表中提取大于一阶的数字,而不使用标准的拆分连接方法等等。最多十个,与 numbers = '0123456789' 的比较有效,比方说,但接下来呢?帮帮我!)我的代码版本如下,但它不区分10(

a = input()
b = []
numbers = '0123456789'
for i in a:
    if i in numbers:
        b.append(int(i))
    else:
        continue
print(b)

вход: 3,5,7,9,10
выход: [3, 5, 7, 9, 1, 0]
python
  • 3 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5