Python Redis usage

Source: Internet
Author: User

#python下redis使用

Install Python Redis plugin: apt-get Install Python-redis edit python connect redis script vi redis_conn.py#!/usr/bin/env pythonimport redisr= Redis. Redis (host= ' localhost ', port=6379,db=0) #r [' Yourkey ']= ' Yourvalue ' def get_redis (host_ip= ' localhost ', port=6379,db=0 ): Return Redis. Redis (host=host_ip,port=port,db=db) enters python command execution: >>>import tab >>>import redis_conn>>> Redis_conn.r.set (' Key1 ', ' value1 ') >>>redis_conn.r[' key1 ']= ' value1 ' >>>redis_conn.r.keys () # View all Key>>>redis_conn.r.delete (' Key1 ') #删除一个key >>>REDIS_CONN.R. [' Key1 '] #获取key1的value >>>redis_conn.r.get (' Key1 ')


This article from "Small East elder brother" blog, declined reprint!

Python Redis usage

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.