小编Abr*_*rar的帖子

从最里面的一对开始,如何反转每对匹配括号中包含的字符串?打架

到目前为止,我已经做到了。我被困在递归上。我不知道如何前进,加入和逆转等。

def callrecursion(s):
    a=s.index('(')
    z=len(s) - string[::-1].index(')') -1
    newStr=s[a+1:z]
# Something is missing here i cant figure it out
    print(newStr)
    return newStr

def reverseParentheses(s):  
    if '(' in s:
        return reverseParentheses(callrecursion(s))        
        print('wabba labba dub dub')
    else:
        return s
string='a(bcdefghijkl(mno)p)q'
reverseParentheses(string)
Run Code Online (Sandbox Code Playgroud)

预期的输出:“ apmnolkjihgfedcbq”

python python-3.x

5
推荐指数
1
解决办法
842
查看次数

错误:无法删除对象,因为其id属性设置为None

尝试使用django中的shell删除对象。如何删除显示“ Ron”的对象?

我使用以下命令:

t.delete('Ron')
Run Code Online (Sandbox Code Playgroud)

django django-models python-3.x

5
推荐指数
1
解决办法
1503
查看次数

如何使用 fill_ Between 创建按月的最小-最大图

我必须将月份名称显示为 xticks,当我绘制图形并将 x 作为月份名称传递时,它会绘制错误。我还必须在线图上叠加散点图。

我无法在此处粘贴完整的代码,因为它是 MOOC 作业,我只是在寻找我在这里做错了什么。

plt.figure(figsize=(8,5))

plt.plot(mint['Mean'],linewidth= 1, label = 'Minumum')
plt.plot(maxt['Mean'],linewidth = 1, label = 'Maximum')

plt.scatter(broken_low,mint15.iloc[broken_low]['Mean'],alpha = 0.75)
plt.scatter(broken_high,maxt15.iloc[broken_high]['Mean'],alpha = .75)
Run Code Online (Sandbox Code Playgroud)

数据集链接在这里:

https://drive.google.com/file/d/1qJnnHDK_0ghmHQl4OuyKDr-0K5ETo7Td/view?usp=sharing

这是它的外观的一个想法

它应该看起来像这样,填充线之间的面积,x 轴为月份,y 轴为摄氏度

python matplotlib pandas

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

sum() 是否占用python3 中循环的执行时间

sum()在循环中使用,执行时间超过4s,sum()这里是否等于嵌套循环?

def arrayMaxConsecutiveSum(inputArray, k):
    cop=k
    lis=[]
    i=0
    while i < len(inputArray):
        inpu=sum(inputArray[i:cop])
        lis.append(inpu)
        cop+=1
        i+=1
    return max(lis)
Run Code Online (Sandbox Code Playgroud)

execution-time python-3.x

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