小编Geo*_*ing的帖子

'int'对象在python中不是可调用的错误

我收到这个错误:

Traceback (most recent call last):
  File "C:\Users\George\Desktop\ex3.py", line 15, in <module>
    s=s+d*2(-1/6.)*(u-1)*(u-2)*(u+2)*(u-4)
TypeError: 'int' object is not callable
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

x=input()
z=input()
n=input()
while x>=z:
    x=input()
    z=input()
while n<0:
    n=input()
while n>0:
    d=(z-x)/1.*n
    k=1
    s=(d/2.)*((-1/6.)*(x-1)*(x-2)*(x+2)*(x-4)+(-1/6.)*(z-1)*(z-2)*(z+2)*(z-4))
    while k<=n-1:
        u=x+k*d
        s=s+d*2(-1/6.)*(u-1)*(u-2)*(u+2)*(u-4)
        k=k+1
        print "%.3f" %s
        x=input()
        z=input()
        n=input()
        if n>0:
            while x>=z:
                x=input()
                z=input()
Run Code Online (Sandbox Code Playgroud)

python int callable

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

'pygame'未定义

我已经安装了pygame(1.9.1 v).这是我的代码:

# 1 - Import library
import pygame
from pygame.locals import *
import math
import random

# 2 - Initialize the game
pygame.init()
width, height = 640, 480
screen=pygame.display.set_mode((width, height))
keys = [False, False, False, False]
playerpos=[100,100]

# 3 - Load images
player = pygame.image.load("resources/images/messi.jpg")
podo = pygame.image.load("resources/images/podo3.png")
podo1 = pygame.image.load("resources/images/podo1.png")

# 4 - keep looping through
while 1:
    # 5 - clear the screen before drawing it again
    screen.fill(0)
    # 6 - draw the screen elements
    for x …
Run Code Online (Sandbox Code Playgroud)

python pygame

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

Python:信用卡验证码

我的代码有问题.它运行良好但在某些情况下(例如输入= 8913266562747895)它给出了错误的答案.这是我的代码:

def ccv(s):
    k=list(s)
    if len(k)==19:
        for i in(0,1,2,3,5,6,7,8,10,11,12,13,15,16,17,18):
            if not k[i].isdigit():
                return False
        for i in(4,9,14):            
            if k[i]!=" " and k[i]!="-":
                return False
        l=[int(c) for c in s if c.isdigit()]
        if not 4<=l[0]and l[0]<=7:
            return False
        s=0
        for i in range(0,16, 2):
            l[i]=2*l[i]
            if l[i]/10!=0:
                l[i]= l[i]/10+(l[i]%10)       
        for i in range(16):
            s=s+l[i]
        return s%10==0
    elif len(k)==16:
        for i in range(16):
            if not k[i].isdigit():
                return False
        l=[int(c) for c in s if c.isdigit()]
        if not 4<=l[0]and l[0]<=7:
            return False …
Run Code Online (Sandbox Code Playgroud)

python validation

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

标签 统计

python ×3

callable ×1

int ×1

pygame ×1

validation ×1