"TypeError: function()最多接受6个参数(给定7个)"

2024-07-03 07:49:02 发布

您现在位置:Python中文网/ 问答频道 /正文

据我所见,我只给了函数6个参数,而不是根据抛出的错误给出7个参数:

mymap.addpoint(float(x[i][7][0]),float(x[i][7][1]), "#0000FF",None,title,str(x[i][0]))
TypeError: addpoint() takes at most 6 arguments (7 given)

有人能帮忙吗?代码如下:

def plotjobs(x,y): #plots the latitude and longitudes of a job on a map (x would be the job dictionary, y is used to differentiate the filename)
    mymap = pygmapsedit.maps(53.644638, -2.526855, 6)
    for i in x:
        title = "<img style = 'float: left' src='some.gif'><img style = 'float: left' src='someother.gif'><div style = 'float: right; width: 200px'><p><b>Route No.:</b> "+str(x[i][0])+"</p><p><b>Postcode:</b> "+str(x[i][1])+"</p><p><b>Visit Date:</b> "+str(x[i][3])+"</p><p><b>Store Name:</b> "+str(x[i][4])+"</p><p><b>Store Address:</b> "+str(x[i][5])+"</p><p><b>Store Telephone No.:</b> "+str(x[i][6])+"</div>"
        mymap.addpoint(float(x[i][7][0]),float(x[i][7][1]), "#0000FF",None,title,None)
    mymap.draw("./"+str(y)+"'s Route.html")

这是我正在使用的模块(pygmaps的编辑版本)中的代码:

def drawpoint(self,f,lat,lon,color,title,windowtext,num):
    f.write('\t\tvar latlng = new google.maps.LatLng(%f, %f);\n'%(lat,lon))
    f.write('\t\tvar img = "http://mapicons.nicolasmollet.com/wp-content/uploads/mapicons/shape-default/color-666666/shapecolor-color/shadow-1/border-dark/symbolstyle-white/symbolshadowstyle-dark/gradient-iphone/number_'+num+'.png";\n') #replace with comment above  to go back to default icon
    if windowtext !=None:
        f.write('\t\tvar info = '+'"'+windowtext+'"'+';\n')
    f.write('\t\tvar infowindow = new google.maps.InfoWindow({\n')
    f.write('\t\t});\n')
    f.write('\t\tvar marker = new google.maps.Marker({\n')
    if title !=None:
        f.write('\t\ttitle: "'+str(title)+'",\n')
    f.write('\t\ticon: img,\n')
    f.write('\t\tposition: latlng,\n')
    f.write('\t\tmap: map,\n')
    f.write('\t\tcontent: info\n')
    f.write('\t\t});\n')
    f.write('\t\tmarker.setMap(map);\n')
    f.write('\n')
    f.write('\t\tgoogle.maps.event.addListener(marker, "click", function(content) {\n')
    f.write('\t\t\tinfowindow.setContent(this.content);\n')
    f.write('\t\t\tinfowindow.open(map,this);\n')
    f.write('\t\t});\n')

Tags: thetostorenonemapimgtitlestyle