因为vs2013没有更新update 5所以Parameters.Add可以用Parameters.AddWithValue赋值无效
更新后可以。
Parameters.AddWithValue的底层实际上还是
Parameters.Add
1)positional,keyword and default parameterFor positional parameters,values are assigned to different parameters according to their positions;def hello_1(greeting, name): print '%s, %s!' % (greeting, name) >>> hello_1('Hello', 'world') Hello, world!
Sometimes (especially if you have many parameters) the order may be hard to remember. To make things easier, you can supply the name of your parameter:>>> hello_1(greeting='Hello', name='world') Hello, world! >>> hello_1(name='world', greeting='Hello') Hello, world!
The parameters that are supplied with a name like this are called keyword parameters.On their own, the key strength of keyword parameters is that they can help clarify the role of each parameter.What really makes keyword arguments rock, however, is that you can give the parameters in the function default values:def hello_3(greeting='Hello', name='world'): print '%s, %s!' % (greeting, name) >>> hello_3() Hello, world!
2)collecting parametersIn the definition of function,such as def func(*param), the star means adding tuple mark "()" for the function argumentsdef print_params(*params): print params >>> print_params(1, 2, 3) (1, 2, 3)
for def func(**param) the double stars means adding dictionary mark "{}" for the function argumentsdef print_params_3(**params): print params >>> print_params_3(x=1, y=2, z=3) {'z': 3, 'x': 1, 'y': 2}
3)Reversing the Processwe also can use the stars to reverse the process of collecting prarameters when calling the function .that is " * " means deleting tuple mark and "**" for dictionary mark:def add(x, y): return x + y params = (1, 2) >>> add(*params) 3 def hello_3(greeting='Hello', name='world'): print '%s, %s!' % (greeting, name) >>> params = {'name': 'Sir Robin', 'greeting': 'Well met'} >>> hello_3(**params) Well met, Sir Robin!
Using * (or **) both when you define and call the function will simply pass the tuple or dictionary right through, so you might as well not have bothered:>>> def with_stars(**kwds): print kwds['name'], 'is', kwds['age'], 'years old' >>> def without_stars(kwds): print kwds['name'], 'is', kwds['age'], 'years old' >>> args = {'name': 'Mr. Gumby', 'age': 42} >>>with_stars(**args) Mr.Gumby is 42 years old >>>without_stars(args) Mr.Gumby is 42 years old
So the stars are really useful only if you use them either when defining a function (to allow a varying number of arguments) or when calling a function (to "splice in" a dictionary or a sequence).
今天在操作Mysql进行删除操作时,出现了这么一个错误。
Parameter index out of range (1 > number of parameters, which is 0)
结合网上各位大佬给出的解答,终于将其解决。
问题出在手写的sql出错。
这个报错的含义指的是第一个参数的问题,也就是说问题出在?左右。
这是我写的sql:
String sql = "DELETE FROM T_PUB_NODE_INFO WHERE C_IP =?";
看起来是不是没有错误。。。
原来是我的问号是中文输入法下的?,不是英文输入下的?。改了之后就好了。
另外网上也有其他错误情况。
例如这样写:
String sql = "DELETE FROM T_PUB_NODE_INFO WHERE C_IP ='?'";
还有在MyBatis下报这个错误可能是你 like 语句写错了。
在mybatis里面写就是应该是 like '%${name} %' 而不是 '%#{name} %' 。
${name} 是不带单引号的,而#{name} 是带单引号的。
喜欢的朋友欢迎点赞,评论,关注哦~~
在做接口并发测试的时候,才发现Jmeter中的Parameters和Body Data两种参数格式并不是简单的一个是xx=xx,另外一个是json格式的参数
先看一个接口
[post] /api/xx/xxxx/xxxx 通知服务端文件上传完毕
输入参数:
http content type: application/json 名称 | 类型 | 是否必须 | 参数限制 | 描述 --------- | ----------- | -------- | ---------- | ---------- cid | string | 是 | cid.length==36 | id version | int | 是 | 无 | 版本
开始时在Jmeter的请求为
请求返回的结果为
{"msg":"{\"message\":\"error\",\"error_code\":4000}","ret":"error"}
查找后发现是Parameters和Body Data的使用,还有请求的参数理解有误
仔细看看抓包中的两种“参数”
xx=xx&xxx=xx格式
json格式
Parameters
xx=xx&xxx=xx格式的参数为GET或者POST请求中,url中带的参数值,如:
在一个这样的请求中
/api/xx/xxx/xxxx?index=0&pagesize=100&thumb=1
?号后面的可以写在url中,也可以写在Parameters中
Body Data
json格式的是POST请求中的参数,POST请求参数时,看请求的格式,是否需要在请求中添加HTTP信息头管理器,将请求的
Content-Type
或者User-Agent
等进行定义HTTP请求的格式:
HTTP信息头管理器:
欢迎关注个人公众号
因为vs2013没有更新update 5所以Parameters.Add可以用Parameters.AddWithValue赋值无效
更新后可以。
Parameters.AddWithValue的底层实际上还是
Parameters.Add
转载于:https://www.cnblogs.com/c-x-a/p/7027408.html