上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 25 下一页
摘要: pandas索引尽量避免写成dfd.loc[0]['a'],会导致赋值失败-- 尽量写成dfd.loc[0, 'a']格式 遇到需要loc与iloc结合的混合索引办法 阅读全文
posted @ 2022-09-13 15:58 CrossPython 阅读(186) 评论(0) 推荐(0)
摘要: import pywifi import time from pywifi import const # WiFi扫描模块 def wifi_scan(): # 初始化wifi wifi = pywifi.PyWiFi() # 使用第一个无线网卡 interface = wifi.interface 阅读全文
posted @ 2022-09-10 22:05 CrossPython 阅读(70) 评论(0) 推荐(0)
摘要: 布署 这是我的目录结构: . ├── Cargo.lock ├── Cargo.toml ├── code.md ├── diesel.toml ├── .env ├── migrations ├── README.md ├── src ├── static └── target 使用cargo r 阅读全文
posted @ 2022-09-09 20:22 CrossPython 阅读(194) 评论(0) 推荐(0)
摘要: https://www.easysap.com/index.php?q-6884.html 阅读全文
posted @ 2022-09-03 07:59 CrossPython 阅读(16) 评论(0) 推荐(0)
摘要: let df = ctx.sql("SELECT distinct \"扫描人\" FROM example").await?;or let df = ctx.sql("SELECT distinct ‘扫描人’ FROM example").await?; => failed. 阅读全文
posted @ 2022-08-21 19:08 CrossPython 阅读(106) 评论(0) 推荐(0)
摘要: struct A<T:Clone>{ data: Vec<T> } type AA = A<usize>; type BB<'a> = A<&'a str>; impl<T:Clone> From<T> for A<T> { fn from(c: T) -> Self { A { data: vec 阅读全文
posted @ 2022-08-16 21:15 CrossPython 阅读(33) 评论(0) 推荐(0)
摘要: (val1 - val2).abs() < f64::EPSILON val1.to_ne_bytes() == val2.to_ne_bytes() 或者 val1.to_bits() == val2.to_bits() 阅读全文
posted @ 2022-08-15 12:40 CrossPython 阅读(138) 评论(0) 推荐(0)
摘要: use std::sync::{Arc, Mutex, Condvar}; use std::thread; use std::cell::RefCell; #[derive(Debug)] struct D{ name: RefCell<String>, data: Vec<i32> } #[de 阅读全文
posted @ 2022-08-10 14:46 CrossPython 阅读(41) 评论(0) 推荐(0)
摘要: Rc<T>/RefCell<T>用于单线程内部可变性, Arc<T>/Mutex<T>用于多线程内部可变性。 阅读全文
posted @ 2022-08-09 10:41 CrossPython 阅读(128) 评论(0) 推荐(0)
摘要: const DEST:(usize, usize) = (7,9); fn try_way(pre:(usize, usize), curr:(usize, usize), map:&[[i32;10];10], route:&mut Vec<(usize, usize)>){ let up:(us 阅读全文
posted @ 2022-08-09 09:55 CrossPython 阅读(29) 评论(0) 推荐(0)
摘要: 一个简单的需求:读入一个目录内的所有文本文件,每个文件的格式都是每一行定义一个二维点,例如x=1,y=2;获取所有点的一个列表。这里不使用serde或者现成的parser库,这么简单的格式直接手写就行了 没有错误处理 先来一个糙快猛的版本。其中用了一个nightly feature str_spli 阅读全文
posted @ 2022-08-06 20:43 CrossPython 阅读(81) 评论(0) 推荐(0)
摘要: use std::cmp::Ordering; #[derive(Debug)] enum D{ F(f64) } fn getnum(s:&D) ->f64{ if let D::F(x) = s{ *x }else{ panic!("no value"); } } impl std::cmp:: 阅读全文
posted @ 2022-08-04 20:34 CrossPython 阅读(38) 评论(0) 推荐(0)
摘要: rust web, salvo, 阅读全文
posted @ 2022-08-03 15:35 CrossPython 阅读(40) 评论(0) 推荐(0)
摘要: path = r'\\c价.xlsx' df = pd.read_excel(path) df = df.sort_values(by='YM', ascending=False) df.dropna(inplace=True) df['cc'] = np.where(df['单价'].str.is 阅读全文
posted @ 2022-08-03 10:38 CrossPython 阅读(381) 评论(0) 推荐(0)
摘要: use chrono::prelude::*; // 1. 时间转字符 // 2. 字符转时间 // 3. 时间相加减 // 4. 时间加差异数 fn main(){ let d = NaiveDate::from_ymd(2015, 3, 14); let a = NaiveDate::from_ 阅读全文
posted @ 2022-08-02 16:41 CrossPython 阅读(264) 评论(0) 推荐(0)
摘要: use std::cmp::Ordering; enum Fruit { Apple(i32), Orange(i32), } fn process_fruit(_apple_prices: &[i32], _orange_prices: &[i32]) { // whatever we do to 阅读全文
posted @ 2022-08-01 11:17 CrossPython 阅读(54) 评论(0) 推荐(0)
摘要: https://zhuanlan.zhihu.com/p/492292655 阅读全文
posted @ 2022-07-30 15:06 CrossPython 阅读(46) 评论(0) 推荐(0)
摘要: #[derive(Debug)] enum Unit{ INT(i32), STR(String), FLOAT(f32) } #[derive(Debug)] struct People{ name: String, elements: Vec<Unit> } impl IntoIterator 阅读全文
posted @ 2022-07-28 13:36 CrossPython 阅读(26) 评论(0) 推荐(0)
摘要: struct CountdownIterator(i32); impl Iterator for CountdownIterator { type Item = i32; fn next(&mut self) -> Option<Self::Item> { self.0 -= 1; if self. 阅读全文
posted @ 2022-07-28 12:26 CrossPython 阅读(23) 评论(0) 推荐(0)
摘要: use std::ptr; use std::fmt::{ Display, Formatter, Result }; pub struct Node { value: i32, next: *mut Node } impl Node { pub fn new(val: i32) -> Self { 阅读全文
posted @ 2022-07-28 11:52 CrossPython 阅读(27) 评论(0) 推荐(0)
摘要: 通过迭代器提供的filter()和collect()方法。 let list2: Vec<_> = (1..=100).filter(|i| i%3 == 0).collect();assert_eq!(list1, list2); take(k)取前面k个元素。 迭代器调用take()后,迭代器的 阅读全文
posted @ 2022-07-28 10:39 CrossPython 阅读(61) 评论(0) 推荐(0)
摘要: use postgres::{Client, NoTls}; fn main(){ let mut client = Client::connect("host=localhost user=postgres password=postgres port=5433", NoTls).unwrap() 阅读全文
posted @ 2022-07-27 13:46 CrossPython 阅读(79) 评论(0) 推荐(0)
摘要: use std::fmt::{Debug, Display}; use std::any::TypeId; use std::any::Any; fn is_string<T: ?Sized + Any>(_s: &T) -> bool { TypeId::of::<String>() == Typ 阅读全文
posted @ 2022-07-25 22:01 CrossPython 阅读(25) 评论(0) 推荐(0)
摘要: mopa = 0.2 use mopa; use std::fmt::Debug; use std::fmt::Display; use std::any::TypeId; fn is_string<T: ?Sized + mopa::Any>(_s: &T) -> bool { TypeId::o 阅读全文
posted @ 2022-07-25 18:38 CrossPython 阅读(19) 评论(0) 推荐(0)
摘要: #[macro_use] extern crate mopa; struct Bear { // This might be a pretty fat bear. fatness: u16, } impl Bear { fn eat(&mut self, person: Box<dyn Person 阅读全文
posted @ 2022-07-25 18:28 CrossPython 阅读(24) 评论(0) 推荐(0)
摘要: downcast-rs = "1.2" // Can call macro via namespace since rust 1.30. use downcast_rs::Downcast; use std::fmt::Debug; // To create a trait with downcas 阅读全文
posted @ 2022-07-24 09:53 CrossPython 阅读(109) 评论(0) 推荐(0)
摘要: use std::any::Any; use core::fmt::Debug; trait ColTrait: std::fmt::Debug{ fn getself<T>(&self)->T; } #[derive(Debug)] struct DataCell<T>{ val:T, } // 阅读全文
posted @ 2022-07-21 13:26 CrossPython 阅读(66) 评论(0) 推荐(0)
摘要: use std::{any::{Any, TypeId}, fmt::Debug}; use downcast_rs::Downcast; fn is_string<T: ?Sized + Any>(_s: &T) -> bool { TypeId::of::<String>() == TypeId 阅读全文
posted @ 2022-07-21 09:19 CrossPython 阅读(53) 评论(0) 推荐(0)
摘要: use std::collections::HashMap; use std::ops::Index; #[derive(Debug,Clone)] struct Cell{ name:String } type Col = HashMap<String, Vec<Cell>>; #[derive( 阅读全文
posted @ 2022-07-20 15:20 CrossPython 阅读(56) 评论(0) 推荐(0)
摘要: https://github.com/jinliming2/Chrome-Charset 阅读全文
posted @ 2022-07-19 13:29 CrossPython 阅读(707) 评论(0) 推荐(0)
摘要: 基本技巧快速启动VsCode安装后,会自动写入环境变量,终端输入code即可唤起VsCode应用程序。 常用快捷键ctrl + p快速搜索文件并跳转,添加:可以跳转到指定行ctrl + shift + p 根据您当前的上下文访问所有可用命令。ctrl + shift + c在外部打开终端并定位到当前 阅读全文
posted @ 2022-07-19 10:13 CrossPython 阅读(214) 评论(0) 推荐(0)
摘要: trait Select<T>{ fn select<'a>(self, slice:&'a Vec<T>)->Vec<&T>; } impl<T> Select<T> for usize { fn select<'a>(self, slice:&'a Vec<T>)->Vec<&T> { matc 阅读全文
posted @ 2022-07-16 23:41 CrossPython 阅读(20) 评论(0) 推荐(0)
摘要: #[derive(Clone, Copy)] enum Args<'a> { Idx(usize), IdxList(&'a [usize]), } fn get_data<'a, T>(arr: &'a [T], idxs: Args<'a>) -> Vec<&'a T> { match idxs 阅读全文
posted @ 2022-07-16 17:54 CrossPython 阅读(67) 评论(0) 推荐(0)
摘要: use std::any::Any; macro_rules! requests{ ( $($key:expr=> $value:expr);* $(;)? ) => { let mut url: Box<dyn Any> = Box::new(""); let mut method: Box<dy 阅读全文
posted @ 2022-07-16 15:26 CrossPython 阅读(131) 评论(0) 推荐(0)
摘要: #[derive(Debug)] enum Cell{ s(String), f(f64), i(i64), b(bool) } #[derive(Debug)] struct Col{ title:String, data:Vec<Cell> } type DataFrame = Vec<Col> 阅读全文
posted @ 2022-07-16 11:54 CrossPython 阅读(10) 评论(0) 推荐(0)
摘要: use std::collections::HashMap; macro_rules! map { ($($key:expr => $val:expr),*) => {{ let mut hm = HashMap::new(); $(hm.insert($key, $val);)* hm }}; / 阅读全文
posted @ 2022-07-15 23:34 CrossPython 阅读(34) 评论(0) 推荐(0)
摘要: #[derive(Debug)] enum Cell { s(String), i(i64), f(f64) } type Col = Vec<Cell>; trait ColumnFactory { fn build(self) -> Cell; } impl ColumnFactory for 阅读全文
posted @ 2022-07-15 22:54 CrossPython 阅读(849) 评论(1) 推荐(1)
摘要: impl Trait:静态分发dyn Trait:动态分发 静态分发:在编译期就确定了具体返回类型,函数只能返回一种类型。动态分发:在运行时才能确定具体返回类型,函数可以返回多种类型。 Trait Object:指向trait的指针,假设Animal是一个triait,那么&Animal和Box<A 阅读全文
posted @ 2022-07-15 10:26 CrossPython 阅读(143) 评论(0) 推荐(0)
摘要: window.setInterval(function(){ var refreshHours = new Date().getHours(); var refreshMin = new Date().getMinutes(); var refreshSec = new Date().getSeco 阅读全文
posted @ 2022-07-14 10:29 CrossPython 阅读(132) 评论(0) 推荐(0)
摘要: 1. var ajax = { abort: function () {} //定义一个空的方法, 是为了下面ajax.abort()不报错 }; setInterval(function () { ajax.abort(); //每次提交前, 先放弃上一次ajax的提交, 这样就不会同时有多个aj 阅读全文
posted @ 2022-07-14 09:53 CrossPython 阅读(414) 评论(0) 推荐(0)
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 25 下一页