mysql函数aver_MySQL函数的使用

以下列出mysql函数的使用,并不完全,涉及到多少写多少。

length(str):返回字符串(str)的字符长度。一个汉字算三个字符,一个数字或字母算一个字符。

select length('测试'); -- 6

select length('123abc'); -- 6

char_length(str):返回字符串(str)的字符长度。一个汉字、数字或字母都算一个字符。

select char_length('测试'); -- 2

select char_length('123abc'); -- 6

instr(str,substr):返回指定字符串(substr)在字符串(str)中的第一次出现的位置。如果未找到则返回0。

select instr('football','f'); -- 1

select instr('football','o'); -- 2

select instr('football','ba'); -- 5

locate(substr,str):返回指定字符串(substr)在字符串(str)中的第一次出现的位置。如果未找到则返回0。

select locate('ba','football'); -- 5

select locate('o','football'); -- 2

locate(substr,str,pos):返回指定字符串(substr)在字符串(str)中的第(pos)位之后第一次出现的位置。如果未找到则返回0。

select locate('o','football',3); -- 3

select locate('o','football',4); -- 0

concat(str1,str2,...):返回所有参数拼接起来产生的字符串。如果有任何一个参数位null,则返回null。

select concat('w','h','at'); -- what

select concat('w','h','at',null); -- null

concat_ws(separator,str1,str2,...):返回所有参数拼接起来产生的字符串,第一个参数作为后面参数拼接的分隔符。如果分隔符为null,则返回null,除分隔符外的其他参数为null,则忽略。

select concat_ws(',','first','second','third'); -- first,second,third

select concat_ws(';','11','22','33',null); -- 11;22;33

select concat_ws(null,'11','22','33',null); -- null

left(str,length):从字符串(str)左起第一个字符开始,返回指定长度(length)的子字符串。

select left('mysql',2); -- my

right(str,length):从字符串(str)右起第一个字符开始,返回指定长度(length)的子字符串。

select right('mysql',3); -- sql

substring(str,pos):返回字符串(str)从第(pos)个字符开始之后的所有字符组成的子字符串。pos为正数,从左起;pos为负数,从右起。

select substring('everyone',3); -- eryone

select substring('everyone',-3); -- one

substring(str,pos,length):返回字符串(str)从第(pos)个字符开始,之后指定长度(length)的子字符串。pos为正数,从左起;pos为负数,从右起。

select substring('everyone',1,5); -- every

select substring('everyone',-3,3); -- one

substring_index(str,delim,count):返回从字符串(str)第一个字符开始,到字符串中第(count)次出现的分隔符(delim)之间的子字符串。count为正数,从左起;count为负数,从右起。

如果在字符串(str)中未找到分隔符(delim)的位置,或者未找到指定次数(count)出现的分隔符的位置时,则返回整个字符串。分隔符(delim)不一定为符号,也可以为其它自定义字符。

select substring_index('11;22;33;',';',2); -- 11;22

select substring_index('11;22;33;',',',2); -- 11;22;33;

select substring_index('11;22;33;',';',-2); -- 33;

convert(value,type):类型或格式转换。可转换的类型是有限制的,可以是以下类型中之一:binary、char(n)、date、time、datetime、decimal、signed、unsigned。

48304ba5e6f9fe08f3fa1abda7d326ab.png

-- 数字转换为字符串

select convert(33,char); -- 33(字符串类型)

-- 字符串转换为数字

select convert('333',signed); -- 333(数字值类型)

-- 把字符串编码格式转换为Unicode编码格式

select convert('一' using ucs2);

-- 把字符串编码格式转换为UTF8编码格式

select convert('abc' using utf8);

-- 把字符串编码格式转换为GBK编码格式

select convert('一' using gbk);

-- 把字符串编码格式转换为GB2312编码格式

select convert('一' using gb2312);

48304ba5e6f9fe08f3fa1abda7d326ab.png

cast(value as type):类型转换。可转换的类型是有限制的,可以是以下类型中之一:binary、char(n)、date、time、datetime、decimal、signed、unsigned。

-- 数字转换为字符串

select cast(333 as char);

-- 字符串转换为数字

select cast('3333' as signed);

hex(str):把指定的字符串(str)转换为16进制值。

-- 把字符串转换为16进制值

select hex(convert('一' using ucs2)); -- 4E00

unhex(str):把指定的16进制字符串(str)转换为字符串。

-- 把16进制值转换为字符串

select convert(unhex('4E00') using ucs2); -- 一

ord(str):把指定的字符串(str)转换为ASCII值。

-- 把字符串转换为ASCII值

select ord(convert('A' using ucs2)); -- 65

select ord(convert('一' using ucs2)); -- 19968

ascii(str):把指定的字符串(str)转换为ASCII值。

-- 把字符串转换为ASCII值

select ascii(convert('A' using utf8)); -- 65

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
torch.save(model.state_dict(), r'./saved_model/' + str(args.arch) + '_' + str(args.batch_size) + '_' + str(args.dataset) + '_' + str(args.epoch) + '.pth') # 计算GFLOPs flops = 0 for name, module in model.named_modules(): if isinstance(module, torch.nn.Conv2d): flops += module.weight.numel() * 2 * module.in_channels * module.out_channels * module.kernel_size[ 0] * module.kernel_size[1] / module.stride[0] / module.stride[1] elif isinstance(module, torch.nn.Linear): flops += module.weight.numel() * 2 * module.in_features start_event = torch.cuda.Event(enable_timing=True) end_event = torch.cuda.Event(enable_timing=True) start_event.record() with torch.no_grad(): output = UNet(args,3,1).to(device) end_event.record() torch.cuda.synchronize() elapsed_time_ms = start_event.elapsed_time(end_event) gflops = flops / (elapsed_time_ms * 10 ** 6) print("GFLOPs: {:.2f}".format(gflops)) return best_iou, aver_iou, aver_dice, aver_hd, aver_accuracy, aver_recall, aver_precision, aver_f1score, aver_memory, fps, parameters, gflops出现错误 best_iou,aver_iou,aver_dice,aver_hd, aver_accuracy, aver_recall, aver_precision, aver_f1score, aver_memory, FPS, parameters, gflops = val(model,best_iou,val_dataloader) File "D:/BaiduNetdiskDownload/0605_ghostv2unet _tunnelcrack/ghostunet++/UNET++/main.py", line 143, in val return best_iou, aver_iou, aver_dice, aver_hd, aver_accuracy, aver_recall, aver_precision, aver_f1score, aver_memory, fps, parameters, gflops UnboundLocalError: local variable 'gflops' referenced before assignment怎么修改
最新发布
06-08

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值