Solution() takes no arguments何解？

``````from typing import List

class Solution:
def jump(self, nums: List[int]) -> int:
counter = 0  # 移动次数
curr_end = 0  # 当前跳跃的终点
curr_farthest = 0  # 最远位置的下标
for i in range(len(nums) - 1):
curr_farthest = max(curr_farthest, i + nums[i])
if i == curr_end:
counter += 1
curr_end = curr_farthest
return counter

a = Solution([2,3,1,1,4])
print(a.jump())
``````

TypeError Traceback (most recent call last)
in
13 return counter
14
---> 15 a = Solution([2,3,1,1,4])
16 print(a.jump())

TypeError: Solution() takes no arguments

2个回答

``````a = Solution()
print(a.jump([2,3,1,1,4]))
``````

3 个月之前 回复

3 个月之前 回复

Python 3.7 使用sorted()函数对列表进行不区分大小写排序时出现TypeError: lower() takes no arguments (1 given)

Python， TypeError: APP() takes no arguments
``` import tkinter as tk class APP(): def _init_(self,master): frame = tk.Frame(master) frame.pack(side = tk.LEFT, padx = 10, pady = 10) self.hi_there = tk.Button(frame,text = "打招呼", bg = 'black',fg = 'white',command = self.say_hi) self.hi_there.pack() def say_hi(self): print("hello everyone") root = tk.Tk() app = APP(root) root.mainloop() ``` 报错信息如下： Traceback (most recent call last): File "D:/py/AboutExcel/Tkinter_4.py", line 17, in <module> app = APP(root) TypeError: APP() takes no arguments Process finished with exit code 1

error_message:insertMysqlseghist() takes 4 positional arguments but 5 were given

R语言 分层抽样函数strata报错： 'match' requires vector arguments？

Lazy Evaluation 怎么实现
function takes at least 2 arguments(1 given)

TypeError: Triangle_2D_3Node_Stiffness() missing 2 required positional arguments: 'j' and 'm'。i，j, m为单元节点坐标,e为单元序号。求大神指导？？？
def Triangle_2D_3Node_Stiffness(E,mu,t,xy,i,j,m,): """ FUNC: this function calculates the element stiffness matrix for a 2D 3 nodes plane element PARA: E -Young's modulus mu -Poisson's ratio t -thick of plate xy -locations of nodes, eg.[(x1,y1),(x2,y2),(x3,y3)] ID -1 for plane stress, 2 for plane strain """ (xi,yi),(xj,yj),(xm,ym) = xy_e A_e = (xi*(yj-ym) + xj*(ym-yi) + xm*(yi-yj))/2 ai, aj, am = xj*ym - xm*yj, xm*yi - xi*ym, xi*yj - xj*yi bi, bj, bm = yj-ym, ym-yi, yi-yj ci, cj, cm = xm-xj, xi-xm, xj-xi B = np.mat([ [bi, 0, bj, 0, bm, 0], [ 0, ci, 0, cj, 0, cm], [cj, bi, cj, bj, cm, bm] ])/(2*A) D = (E/(1-mu**2))*np.mat([ [ 1, mu, 0], [mu, 1, 0], [ 0, 0, (1-mu)/2] ]) k_e = t*A*np.transpose(B)*D*B return k
too few arguments for variable template "set"
```#include<iostream> #include<cstdio> #include<algorithm> #include<set> using namespace std; const int maxn=200000+5; int a[maxn],f[maxn],g[maxn]; struct candidate{ int a,g; candidate(int a,int g):a(a),g(g){} bool operator < (const candidate& rhs) const{ return a<rhs.a; } }; set<candidate > s; //以下省略 ``` vs中编译报错：too few arguments for variable template "set" 使用map 《int，int 》m；时也报错：too few arguments for variable template "map" 已经包含了头文件的情况下也报错，且编译运行失败。 请问是什么原因以及如何解决？
TensorFlow初始化一个权重矩阵时报了这个错误，想请教一下大家是怎么回事
ValueError: You can only pass an initializer function that expects no arguments to its callable when the shape is not fully defined. The given initializer function expects the following args ['self', 'shape', 'dtype', 'partition_info']
Polish notation 程序的编写
Problem Description Reverse Polish notation (RPN) is a method for representing expressions in which the operator symbol is placed after the arguments being operated on. Polish notation, in which the operator comes before the operands, was invented in the 1920s by the Polish mathematician Jan Lucasiewicz. In the late 1950s, Australian philosopher and computer scientist Charles L. Hamblin suggested placing the operator after the operands and hence created reverse polish notation. RPN has the property that brackets are not required to represent the order of evaluation or grouping of the terms. RPN expressions are simply evaluated from left to right and this greatly simplifies the computation of the expression within computer programs. As an example, the arithmetic expression (3+4)*5 can be expressed in RPN as 3 4 + 5 *. Reverse Polish notation, also known as postfix notation, contrasts with the infix notation of standard arithmetic expressions in which the operator symbol appears between the operands. So Polish notation just as prefix notation. Now, give you a string of standard arithmetic expressions, please tell me the Polish notation and the value of expressions. Input There're have multi-case. Every case put in one line, the expressions just contain some positive integers(all less than 100, the number of integers less than 20), bi-operand operators(only have 3 kinds : +,-,*) and some brackets'(',')'. you can assume the expressions was valid. Output Each case output the Polish notation in first line, and the result of expressions was output in second line. all of the answers are no any spaces and blank line.the answer will be not exceed the 64-signed integer. Sample Input 1+2-3*(4-5) 1+2*(3-4)-5*6 Sample Output Case 1: - + 1 2 * 3 - 4 5 6 Case 2: - + 1 * 2 - 3 4 * 5 6 -31
python中报TypeError: __init__() missing 2 required positional arguments: 'url' and 'method'
demo1.py代码如下： import requests class RunMain: def __init__(self,url,method,data=None): self.res = self.run_main(url,method,data) def send_get(self,url,data): res = requests.get(url=url,data=data) return res.json() def send_post(self,url,data): res = requests.post(url=url,data=data) return res.json() def run_main(self,url,method,data=None): res = None if method == 'GET': res = self.send_get(url,data) else: res = self.send_post(url,data) return res if __name__ == '__main__': url = 'http://www.imooc.com/m/web/shizhanapi/loadmorepingjia.html' data = { 'cart': '11' } run = RunMain(url,'GET',data) print(run.res) test_method1.py代码如下： #coding = utf-8 import unittest from demo1 import RunMain class TestMethod(unittest.TestCase): def setUp(self): self.run = RunMain() def test_01(self): url = 'http://coding.imooc.com/api/cate' data = { 'timestamp': '1507034803124', 'uid': '5249191', 'uuid': '5ae7d1a22c82fb89c78f603420870ad7', 'secrect': '078474b41dd37ddd5efeb04aa591ec12', 'token': '7d6f14f21ec96d755de41e6c076758dd', 'cid': '0' } res = self.run.run_main(url,'POST',data) print(res) def test_02(self): url = 'http://coding.imooc.com/api/cate' data = { 'timestamp': '1507034803124', 'uid': '5249192', 'uuid': '5ae7d1a22c82fb89c78f603420870ad7', 'secrect': '078474b41dd37ddd5efeb04aa591ec12', 'token': '7d6f14f21ec96d755de41e6c076758dd', 'cid': '0' } res = self.run.run_main(url,'POST',data) print(res) if __name__ == '__main__': unittest.main(url,method) 但是报如下错误： Error Traceback (most recent call last): File "E:\MyLeaning\Python36-32\lib\unittest\case.py", line 59, in testPartExecutor yield File "E:\MyLeaning\Python36-32\lib\unittest\case.py", line 601, in run self.setUp() File "D:\www\ImoocInterface\base\test_method1.py", line 7, in setUp self.run = RunMain() TypeError: __init__() missing 2 required positional arguments: 'url' and 'method' ``` ```
springboot绑定数据错误，希望大牛帮帮小白
unity 取消电脑自动关机
public InputField inputField; public void OnClickOKBtn() { System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.Arguments = "/c " + "shutdown -s -t " + (int.Parse(inputField.text) * 60).ToString(); p.Start(); } public void OnClickCancelBtn() { System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.Arguments = "/c " + "shutdown -a"; } ``` OnClickOKBtn()是定时关机，OnclickCancelBtn却没办法取消。 ```
Finding Seats 的解答
Problem Description A group of K friends is going to see a movie. However, they are too late to get good tickets, so they are looking for a good way to sit all nearby. Since they are all science students, they decided to come up with an optimization problem instead of going on with informal arguments to decide which tickets to buy. The movie theater has R rows of C seats each, and they can see a map with the currently available seats marked. They decided that seating close to each other is all that matters, even if that means seating in the front row where the screen is so big it’s impossible to see it all at once. In order to have a formal criteria, they thought they would buy seats in order to minimize the extension of their group. The extension is defined as the area of the smallest rectangle with sides parallel to the seats that contains all bought seats. The area of a rectangle is the number of seats contained in it. They’ve taken out a laptop and pointed at you to help them find those desired seats. Input Each test case will consist on several lines. The first line will contain three positive integers R, C and K as explained above (1 <= R,C <= 300, 1 <= K <= R × C). The next R lines will contain exactly C characters each. The j-th character of the i-th line will be ‘X’ if the j-th seat on the i-th row is taken or ‘.’ if it is available. There will always be at least K available seats in total. Input is terminated with R = C = K = 0. Output For each test case, output a single line containing the minimum extension the group can have. Sample Input 3 5 5 ...XX .X.XX XX... 5 6 6 ..X.X. .XXX.. .XX.X. .XXX.X .XX.XX 0 0 0 Sample Output 6 9
knn猫狗识别算法中样本为0报错

python face_recognition库中使用其他的功能都可以正常运行，但只有用face_encodings会报错？

android studio 导入github项目出错：startup failed
Java学习的正确打开方式

linux系列之常用运维命令整理笔录

Python十大装B语法
Python 是一种代表简单思想的语言，其语法相对简单，很容易上手。不过，如果就此小视 Python 语法的精妙和深邃，那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点，并附上详细的实例代码。如能在实战中融会贯通、灵活使用，必将使代码更为精炼、高效，同时也会极大提升代码B格，使之看上去更老练，读起来更优雅。

2019年11月中国大陆编程语言排行榜
2019年11月2日，我统计了某招聘网站，获得有效程序员招聘数据9万条。针对招聘信息，提取编程语言关键字，并统计如下： 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...

《奇巧淫技》系列-python！！每天早上八点自动发送天气预报邮件到QQ邮箱

SQL-小白最佳入门sql查询一

redis分布式锁，面试官请随便问，我都会

Nginx 原理和架构
Nginx 是一个免费的，开源的，高性能的 HTTP 服务器和反向代理，以及 IMAP / POP3 代理服务器。Nginx 以其高性能，稳定性，丰富的功能，简单的配置和低资源消耗而闻名。 Nginx 的整体架构 Nginx 里有一个 master 进程和多个 worker 进程。master 进程并不处理网络请求，主要负责调度工作进程：加载配置、启动工作进程及非停升级。worker 进程负责处...
Python 编程开发 实用经验和技巧
Python是一门很灵活的语言，也有很多实用的方法，有时候实现一个功能可以用多种方法实现，我这里总结了一些常用的方法和技巧，包括小数保留指定位小数、判断变量的数据类型、类方法@classmethod、制表符中文对齐、遍历字典、datetime.timedelta的使用等，会持续更新......
Idon’t know what that dream is that you have, I don't care how disappointing it might have been as you've been working toward that dream,but that dream that you’re holding in your mind, that it’s po...
“狗屁不通文章生成器”登顶GitHub热榜，分分钟写出万字形式主义大作

《程序人生》系列-这个程序员只用了20行代码就拿了冠军

11月8日，由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办，科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。 　　区块链技术被认为是继蒸汽机、电力、互联网之后，下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力，电力解决了人类基本的生活需求，互联网彻底改变了信息传递的方式，区块链作为构造信任的技术有重要的价值。 　　1...
Java世界最常用的工具类库
Apache Commons Apache Commons有很多子项目 Google Guava 参考博客