erlang 技巧备忘
来源:互联网 发布:flac转mp3 for mac 编辑:程序博客网 时间:2024/05/16 18:31
我的原文在:http://jiorry.iteye.com/blog/1202231
1. 左补齐 padding left
io:format("~4..Ts~n", ["a"]). -> TTTa
io:format("~4..0B~n", [1]). -> 0001
文档里介绍的具体语法:The general format of a control sequence is ~F.P.PadModC .
F:长度
P:保留小数位数
Pad:补齐的字符串
Mod:模式,即,~s|~w|~B
C:The character C determines the type of control sequence to be used. 还理解的不是很清楚
FP为任意数字
2. io:format | io_lib:format
io:format("~4..0B~n", [1]) -> 0001 默认直接写入当前的输出流
io_lib:format("~4..0B~n", [1]) -> [["000", "a"], "\n"] 返回了一个字符串列表
3. {ok, Columns, _Rows=[R]} = db:find(Sql).
其中的_Rows 为占位变量,只是标识一下变量的意义。_Rows=[R] 标识和赋值一并完成。
4. 得到当前时间的字符串
{Year, Mon, Day} = date(),
{Hour, Min, Sec} = time(),
io_lib:format("~B-~2..0B-~2..0B ~2..0B:~2..0B:~2..0B", [Year, Mon, Day, Hour, Min, Sec]).
5. 字符串转换成整数
string_to_int(Bin) when is_binary(Bin) ->
string_to_int(binary_to_list(Bin));
string_to_int(Str) when is_list(Str) ->
{I, []} = string:to_integer(Str),
I.
6. aes 加密
crypto:aes_cfb_128_encrypt(Key, IVec , Text )
crypto:aes_cfb_128_decrypt(Key, IVec , Text )
文档:Text must be a multiple of 128 bits (16 bytes). Key is the AES key, and IVec is an arbitrary initializing vector. The lengths ofKey andIVec must be 128 bits (16 bytes).
Key,IVec必须为128bits, Text必须为128bit的倍数,不足的话补足。呵呵,不仔细看的话,会被折磨的。
边写erlang边更新,不写不更新...
- erlang 技巧备忘
- Erlang技巧备忘
- erlang 备忘
- Erlang的Makefile文件备忘
- erlang 位语言运算 备忘
- Erlang的Emakefile文件备忘
- [Erlang]Mnesia常用技巧
- Firefox技巧备忘
- Windows技巧备忘
- 工作技巧备忘
- Matlab常用技巧备忘
- linux 小技巧备忘
- zmud之技巧备忘
- eclipse 使用技巧备忘
- Excel 备忘技巧
- google搜索技巧备忘
- 算法小技巧-备忘
- Eclipse常用技巧(备忘)
- 初学.bat,贴在这儿让人笑话
- 百度贴吧中的匿名回复,根本不是匿名,完全可以看到用户的全部IP。
- 计算机等级考试查询
- 捕捉 flash socket 连接超时
- Java SSL 自签名证书生成
- erlang 技巧备忘
- Android之基础复习2D图形一
- erlang 中的 binary 和 binstring类型
- erlang 位语言运算 备忘
- 2.3.5刷机教程(亲测MOTOME525)
- 圆周率的精确解
- ftnchek Fortran 代码检查的利器
- 使用masterpage时,js访问服务端控件
- 写给程序员的一封信