redis操作 先导入redis模块 import redis def main(): client = redis.Redis(host='127.0.0.1', port=6379, password='') print(client) client.set('username', 'hellokitty', ex=300) print(client.get('username')) if __name__ == '__main__': main()