fnmain() { let tup = (500, 6.4, 1); let (_x, y, _z) = tup; println!("The value of y is: {}", y); }
然后重新编译一下:
1 2 3 4
Compiling learn_rust_by_example v0.1.0 (F:\workspace\rust\learn_rust_by_example) Finished dev [unoptimized + debuginfo] target(s) in 0.90s Running `target\debug\learn_rust_by_example.exe` The value of y is: 6.4
println!("The value of y is: {}, x is {}", y,_x); }
结果如下:
1 2 3 4
Compiling learn_rust v0.1.0 (/Users/leetao/Workspace/rt/learn_rust) Finished dev [unoptimized + debuginfo] target(s) in2.86s Running `target/debug/learn_rust` The value of y is: 6.4, x is 500
eg:_
1 2 3 4 5
fnmain() { let tup = (500, 6.4, 1); let (_x, _y, _) = tup; println!("The value of _ is {}", _); }
结果如下:
1 2 3 4 5 6 7 8
Compiling learn_rust v0.1.0 (/Users/leetao/Workspace/rt/learn_rust) error: expected expression, found reserved identifier `_` --> src/main.rs:4:39 | 4 | println!("The value of _ is {}", _); | ^ expected expression
fnmain() { let x: (i32, f64, u8) = (500, 6.4, 1); let first = x.0; // 索引值也是从 0 开始 let second = x.1; let third = x.2; println!("first :{}, second:{}, third: {}",first,second,third); }
看一下编辑结果:
1 2 3 4
Compiling learn_rust v0.1.0 (/Users/leetao/Workspace/rt/learn_rust) Finished dev [unoptimized + debuginfo] target(s) in0.46s Running `target/debug/learn_rust` first :500, second:6.4, third: 1
fnmain() { let a = [1, 2, 3, 4, 5]; // 写法一 // let a: [i32; 5] = [1, 2, 3, 4, 5]; 写法二 let first = a[0]; let second = a[1]; println!("first:{}, second:{}",first,second); }
fnmain() { let a = [1, 2, 3, 4, 5]; let index = 10; let element = a[index]; println!("The value of element is: {}", element); }
看一下结果:
1 2 3 4 5
Compiling learn_rust v0.1.0 (/Users/leetao/Workspace/rt/learn_rust) Finished dev [unoptimized + debuginfo] target(s) in0.07s Running `target/debug/learn_rust` thread 'main' panicked at 'index out of bounds: the len is 5 but the index is 10', src/main.rs:4:19 note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
_class _fields.``DateTime(dt_format=’rfc822’, **kwargs) Return a formatted datetime string in UTC. Supported formats are RFC 822 and ISO 8601. See email.utils.formatdate() for more info on the RFC 822 format. See datetime.datetime.isoformat() for more info on the ISO 8601 format.
通过文档可以得知使用 fields.DateTime 返回的字符串是 UTC 即时间标准时间,很明显和我们不是一个时区的。并且支持的格式只有 RFC 822** **和 **ISO 8601**,还很贴心的给了说明链接。那么这俩个格式时间是什么样子呢?看一下例子:
1 2 3 4
# RFC 2822, Fri, 09 Nov 2001 01:08:47 -0000 # ISO 8601 2019-05-18T15:17:08.132263
Traceback (most recent call last): File "<console>", line 1, in <module> File "c:\programdata\anaconda3\lib\sqlite3\__init__.py", line 23, in <module> from sqlite3.dbapi2 import * File "c:\programdata\anaconda3\lib\sqlite3\dbapi2.py", line 27, in <module> from _sqlite3 import * ImportError: DLL load failed: The specified module could not be found.