Redis的Util工具类,超好用!

Stella981
• 阅读 432

package com.lgdz.zhenshiUtil;

import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPoolConfig;

import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set;

_/** _ * Redis _公共类 _ _* _ * @author xizhuangchui _ * @createDate 2015-6-27 16:39:40 _ */ public class RedisUtil { private static JedisPool pool = null; public static String ip = "127.0.0.1"; public static int port = 6379; /** _ * 十分钟(600__秒) _ */ public static int SMS_TIME = 10 * 60;

_/\*\*

_ * _构建__redis__连接池 _ _* _ * @return _JedisPool _ */ public static JedisPool getPool() { if (pool == null) { JedisPoolConfig config = new JedisPoolConfig(); _//__控制一个__pool__最多有多少个状态为__idle(空闲的)__的__jedis__实例。 _ config.setMaxIdle(500); _//__在__borrow__一个__jedis__实例时,是否提前进行__validate__操作;如果为__true__,则得到的__jedis__实例均是可用的; _ config.setTestOnBorrow(true); _/* Properties properties = BaseConfig.getSysProperties();*/ _ _/* InputStream in = RedisUtil.class.getResourceAsStream("../../../redis.properties"); //---------------------_这个是文件的路径(注意区别很简单,就是加上包的路径) try { properties.load(in); } catch (IOException e) { e.printStackTrace(); } _*/ _ RedisUtil.ip = "127.0.0.1"; RedisUtil.port = 6379; pool = new JedisPool(config, ip, port); } return pool; }

_/\*\*

_ * _返还到连接池 _ _* _ * @param pool _redis__连接池 _ * @param redis _redis__对象 _ _*/ _ public static void returnResource(JedisPool pool, Jedis redis) { if (redis != null) { pool.returnResource(redis); } }

_/\*\*

_ * _获取数据 _ _* _ * @param key _key__的值 _ * @return _String value__的值 _ _*/ _ public static String get(String key) { String value = null;

    JedisPool pool = **null**;
    Jedis jedis = **null**;
    **try** {
        pool = _getPool_();
        jedis = pool.getResource();
        value = jedis.get(key);
    } **catch** (Exception e) {
        _//__释放__redis__对象

_ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); }

    **return** value;
}

_/\*\*

_ * _插入数据 _ _* _ * @param _key _ * @param _value _ * @return Boolean _返回插入状态 _ _*/ _ public static Boolean set(String key, String value) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); jedis.set(key, value); return true; } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return false; } finally { _//__返还到连接池 _ returnResource(pool, jedis); }

}

_/\*\*

_ * _若__key__不存在则储存 _ _* _ * @param _key _ * @param _value _ * @return Long _成功操作的个数 _ _*/ _ public static Long setnx(String key, String value) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.setnx(key, value); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _设置__key__的过期时间,单位:秒,如果__key__在超时之前被修改,则该键关联的超时将被移除。 _ _* _ * @param _key _ * @param seconds _超时时间(秒) _ * @param _value _ * @return 正常返回 _OK _ */ public static String setex(String key, int seconds, String value) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.setex(key, seconds, value); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * 设置 _list _ * * @param _ _ * @param _key _ _*/ _ public static <T> Boolean setexList(String key, List<T> list) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); jedis.set(key.getBytes(), ObjectTranscoder.serialize(list)); return true; } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return false; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * 设置 _list _ * * @param _ _ * @param _key _ _*/ _ public static <T> Boolean setexList(String key, int seconds, List<T> list) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); jedis.setex(key.getBytes(), seconds, ObjectTranscoder.serialize(list)); return true; } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return false; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _获取__list _ * * @param _ _ * @param _key _ * @return _list _ */ public static <T> List<T> getList(String key) { String value = null; JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); value = jedis.get(key); byte[] in = jedis.get(key.getBytes()); List<T> list = (List<T>) ObjectTranscoder.deserialize(in); return list; } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * 设置 _map _ * * @param _ _ * @param _key _ _*/ _ public static <T> Boolean setMap(String key, Map<String, T> map) {

    JedisPool pool = **null**;
    Jedis jedis = **null**;
    **try** {
        pool = _getPool_();
        jedis = pool.getResource();
        jedis.set(key.getBytes(), ObjectTranscoder._serialize_(map));
        **return true**;
    } **catch** (Exception e) {
        _//__释放__redis__对象

_ pool.returnBrokenResource(jedis); e.printStackTrace(); return false; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * 设置 _map _ * * @param _ _ * @param _key _ _*/ _ public <T> Boolean setesMap(String key, int seconds, Map<String, T> map) {

    JedisPool pool = **null**;
    Jedis jedis = **null**;
    **try** {
        pool = _getPool_();
        jedis = pool.getResource();
        jedis.setex(key.getBytes(), seconds, ObjectTranscoder._serialize_(map));
        **return true**;
    } **catch** (Exception e) {
        _//__释放__redis__对象

_ pool.returnBrokenResource(jedis); e.printStackTrace(); return false; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _获取__list _ * * @param _ _ * @param _key _ * @return _list _ */ public <T> Map<String, T> getMap(String key) {

    String value = **null**;
    JedisPool pool = **null**;
    Jedis jedis = **null**;
    **try** {
        pool = _getPool_();
        jedis = pool.getResource();
        value = jedis.get(key);
        **byte**\[\] in = jedis.get(key.getBytes());
        Map<String, T\> map = (Map<String, T\>) ObjectTranscoder._deserialize_(in);
        **return** map;
    } **catch** (Exception e) {
        _//__释放__redis__对象

_ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _设置 _ _* _ * @param _ _ * @param _key _ _*/ _ public static <T> Boolean setexObject(String key, int seconds, Object o) {

    JedisPool pool = **null**;
    Jedis jedis = **null**;
    **try** {
        pool = _getPool_();
        jedis = pool.getResource();
        jedis.setex(key.getBytes(), seconds, ObjectTranscoder._serialize_(o));
        **return true**;
    } **catch** (Exception e) {
        _//__释放__redis__对象

_ pool.returnBrokenResource(jedis); e.printStackTrace(); return false; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _设置 _ _* _ * @param _ _ * @param _key _ _*/ _ public static <T> Boolean setObject(String key, Object o) {

    JedisPool pool = **null**;
    Jedis jedis = **null**;
    **try** {
        pool = _getPool_();
        jedis = pool.getResource();
        jedis.set(key.getBytes(), ObjectTranscoder._serialize_(o));
        **return true**;
    } **catch** (Exception e) {
        _//__释放__redis__对象

_ pool.returnBrokenResource(jedis); e.printStackTrace(); return false; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _获取__list _ * * @param _key _ * @return _list _ */ public static Object getObject(String key) {

    String value = **null**;
    JedisPool pool = **null**;
    Jedis jedis = **null**;
    **try** {
        pool = _getPool_();
        jedis = pool.getResource();
        value = jedis.get(key);
        **byte**\[\] in = jedis.get(key.getBytes());
        Object o = ObjectTranscoder._deserialize_(in);
        **return** o;
    } **catch** (Exception e) {
        _//__释放__redis__对象

_ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _设置__key__对应的一条数据超时时间 _ _* _ * @param _key _ * @param milliseconds _超时的时间(毫秒) _ * @return _成功操作的个数 _ _*/ _ public static Long expire(String key, int milliseconds) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource();

        **return** jedis.expire(key, milliseconds);
    } **catch** (Exception e) {
        _//__释放__redis__对象

_ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _指定超时时间 _ _* _ * @param _key _ * @param millisecondsTimestamp _超时时间的时间戳 _ * @return _成功返回__1__失败返回__0 _ */ public static Long expireAt(String key, long millisecondsTimestamp) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.expireAt(key, millisecondsTimestamp); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _查询剩余时间 _ _* _ * @param _key _ * @return _剩余时间 _ _*/ _ public static Long ttl(String key) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.ttl(key); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _判断__key__是否存在 _ _* _ * @param _key _ * @return _Boolean _ */ public static Boolean exists(String key) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); jedis.exists(key); return true; } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return false; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _删除多个 _ _* _ * @param keys _key__数组 _ * @return _成功操作的个数 _ _*/ _ public static Long del(String[] keys) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.del(keys); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _删除一个 _ _* _ * @param _key _ * @return _成功操作的个数 _ _*/ _ public static Long del(String key) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.del(key); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _返回指定__Map__中的__key__集合 _ _* _ * @param _pattern _ * _@return _ _*/ _ public static Set gethKeys(String pattern) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.hkeys(pattern); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _返回指定__Map__中的__values__集合 _ _* _ * @param _key _ * _@return _ _*/ _ public static List gethVals(String key) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.hvals(key); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _修改__key _ * * @param _oldkey _ * @param _newkey _ * _@return _ _*/ _ public static String rename(String oldkey, String newkey) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.rename(oldkey, newkey); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _如果不存在则修改__key _ * * @param _oldkey _ * @param _newkey _ * _@return _ _*/ _ public static Long renamenx(String oldkey, String newkey) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.renamenx(oldkey, newkey); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _获取__value__,并重新赋值 _ _* _ * @param _key _ * @param _value _ * _@return _ _*/ _ public static String getSet(String key, String value) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.getSet(key, value); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _给__value__追加值 _ _* _ * @param _key _ * @param _value _ * _@return _ _*/ _ public static Long append(String key, String value) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.append(key, value); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _获取指定位置的__value__值 _ _* _ * @param _key _ * @param _start _ * @param _end _ * _@return _ _*/ _ public static String substr(String key, int start, int end) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.substr(key, start, end); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _存入__map__数据 _ _* _ * @param _key _ * @param _hash _ * _@return _ _*/ _ public static String sethm(String key, Map<String, String> hash) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.hmset(key, hash); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _存入__MAP__并设置超时 _ _* _ * @param _key _ * @param seconds 超时时间(秒) _ * @param hash Map<String__, String> _ * @return _Boolean _ */ public static Boolean sethmExpire(String key, int seconds, Map<String, String> hash) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); String state = jedis.hmset(key, hash); if (state.equals("OK")) { jedis.expire(key, seconds); } else { return false; } return true; } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return false; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _插入__map__指定的__key__对应的__value _ * * @param _key _ * @param _field _ * @param _value _ * _@return _ _*/ _ public static Long seth(String key, String field, String value) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.hset(key, field, value); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _若不存在则插入__map__指定的__key__对应的__value _ * * @param _key _ * @param _field _ * @param _value _ * _@return _ _*/ _ public static Long sethnx(String key, String field, String value) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.hsetnx(key, field, value); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _获取__map__指定的__key__对应的__value _ * * @param _key _ * @param _fields _ * _@return _ _*/ _ public static List gethm(String key, String fields) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.hmget(key, fields); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _删除__map__指定的__key _ * * @param _key _ * @param _fields _ * _@return _ _*/ _ public static Long delh(String key, String fields) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.hdel(key, fields); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _获取指定__key__的__MAP _ * * @param _key _ * @return Map<_String_, _String_> _*/ _ public static Map<String, String> gethAll(String key) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.hgetAll(key); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } }

_/\*\*

_ * _批量删除以指定前缀开头的__KEYS _ * @param PrefixStr _前缀 _ _*/ _ public static Long delkeysforPrefixStr(String PrefixStr){ JedisPool pool = null; Jedis jedis = null; Long x= (long)0;

    **try** {
        pool = _getPool_();
        jedis = pool.getResource();

        String pre\_str = PrefixStr;

        Set<String> set = jedis.keys(pre\_str + **"\*"**);

        Iterator<String> it = set.iterator();
    System._out_.println(**"keys:"**+set);
      _//__计数删除了多少__key_ 

while (it.hasNext()) { String keyStr = it.next();

            System._out_.println(keyStr);
            jedis.del(keyStr);
            x++;
        }

    } **catch** (Exception e) {

        pool.returnBrokenResource(jedis);
        e.printStackTrace();
        **return null**;

    } **finally** {

        _//__返还到连接池

_ returnResource(pool, jedis); }

    **return** x;

}

**public static void** main(String\[\] args) {
  _/\*  String message = "C0700000000000046A100G10000001";_ 

set("test", message); System.out.println(get("test"));*/ _//_批量删除以某个字符串为前缀的__keys _ delkeysforPrefixStr("qq"); //存__key__:"offLine192.168.10.25" 时间:__90__秒 数据:"1" _ setex("offLine192.168.10.25",90,"1"); }

_/\*\*

_ * _生成序列号 _ _* _ * _@return _ _*/ _ public static Long incr(String key) { JedisPool pool = null; Jedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); return jedis.incr(key); } catch (Exception e) { _//__释放__redis__对象 _ pool.returnBrokenResource(jedis); e.printStackTrace(); return null; } finally { _//__返还到连接池 _ returnResource(pool, jedis); } } }

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Wesley13 Wesley13
3年前
java将前端的json数组字符串转换为列表
记录下在前端通过ajax提交了一个json数组的字符串,在后端如何转换为列表。前端数据转化与请求varcontracts{id:'1',name:'yanggb合同1'},{id:'2',name:'yanggb合同2'},{id:'3',name:'yang
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
4个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Wesley13 Wesley13
3年前
Redis分布式锁
packagecom.sqi;importredis.clients.jedis.Jedis;importredis.clients.jedis.JedisPool;importredis.clients.jedis.params.SetParams;importjava.util.\;importjava.util.concur
Stella981 Stella981
3年前
Redis进阶应用:Redis+Lua脚本实现符合操作
!(https://oscimg.oschina.net/oscnet/835168748db35a7a20a2e4f148db89ce4f8.png)一、引言Redis是高性能的keyvalue数据库,在很大程度克服了memcached这类key/value存储的不足,在部分场景下,是对关系数据库的良好补充。得益于超
Wesley13 Wesley13
3年前
35岁是技术人的天花板吗?
35岁是技术人的天花板吗?我非常不认同“35岁现象”,人类没有那么脆弱,人类的智力不会说是35岁之后就停止发展,更不是说35岁之后就没有机会了。马云35岁还在教书,任正非35岁还在工厂上班。为什么技术人员到35岁就应该退役了呢?所以35岁根本就不是一个问题,我今年已经37岁了,我发现我才刚刚找到自己的节奏,刚刚上路。
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
10个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这