0

0

深入了解python之rabbitMQ使用

高洛峰

高洛峰

发布时间:2017-03-15 14:16:34

|

6325人浏览过

|

来源于php中文网

原创

前言:这次整理写一篇关于rabbitmq的,感觉rabbitmq难度是提高不少。这篇博客会插入一些英文讲解,不过不难理解的。rabbitmq的下载与安装,请参考redis&rabbitmq安装。

rabbitMQ是消息队列;想想之前的我们学过队列queue:threading queue(线程queue,多个线程之间进行数据交互)、进程Queue(父进程与子进程进行交互或者同属于同一父进程下的多个子进程进行交互);如果两个独立的程序,那么之间是不能通过queue进行交互的,这时候我们就需要一个中间代理即rabbitMQ.

 

一、简单的rabbitMQ队列通信

深入了解python之rabbitMQ使用

由上图可知,数据是先发给exchange交换器,exchage再发给相应队列。pika模块是python对rabbitMQ的API接口。接收端有一个回调函数一接收到数据就调用该函数。一条消息被一个消费者接收后,该消息就从队列删除。OK,了解上面的知识后,先来看看一个简单的rabbitMQ列队通信。

立即学习Python免费学习笔记(深入)”;

send端:

import pika
#连上rabbitMQ
connection=pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel=connection.channel()       #生成管道,在管道里跑不同的队列

#声明queue
channel.queue_declare(queue='hello1')

#n RabbitMQ a message can never be sent directly to the queue,it always needs to go through an exchange.
#向队列里发数据
channel.basic_publish(exchange='',      #先把数据发给exchange交换器,exchage再发给相应队列
                      routing_key='hello1', #向"hello'队列发数据
                      body='HelloWorld!!')  #发的消息
print("[x]Sent'HelloWorld!'")
connection.close()

receive端:

import pika

connection=pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel=connection.channel()

# You may ask why we declare the queue again ‒ we have already declared it in our previous code.
# We could avoid that if we were sure that the queue already exists. For example if send.py program
# was run before. But we're not yet sure which program to run first. In such cases it's a good
# practice to repeat declaring the queue in both programs.
channel.queue_declare(queue='hello1')#声明队列,保证程序不出错


def callback(ch,method,properties,body):
    print("-->ch",ch)
    print("-->method",method)
    print("-->properties",properties)
    print("[x] Received %r" % body)         #一条消息被一个消费者接收后,该消息就从队列删除


channel.basic_consume(callback,              #回调函数,一接收到消息就调用回调函数
                      queue='hello1',
                      no_ack=False)    #消费完毕后向服务端发送一个确认,默认为False

print('[*] Waiting for messages.To exit press CTRL+C')
channel.start_consuming()

运行结果:(上面的代码对应我写的注释相信是看得懂的~)

rabbitMQ_1_send.py
 [x] Sent 'Hello World!'


rabbitMQ_2_receive.py
 [*] Waiting for messages. To exit press CTRL+C
-->ch 
-->method 
-->properties 
 [x] Received b'Hello World!!'

经过深入的测试,有以下两个发现:

  1. 先运行rabbitMQ_1_send.py发送数据,rabbitMQ_2_receive.py未运行。发现当receive运行时仍能接收数据。

  2. 运行多个(eg:3个)接收数据的客户端,再运行发送端,客户端1收到数据,再运行发送端,客户端2收到数据,再运行发送端,客户端3收到数据。

RabbitMQ会默认把p发的消息依次分发给各个消费者(c),跟负载均衡差不多。

 

二、全英文ack

在看上面的例子,你会发现有一句代码no_ack=False(消费完毕后向服务端发送一个确认,默认为False),以我英语四级飘过的水平,看完下面关于ack的讲解感觉写得很牛啊!!于是分享一下:

Doing a task can take a few seconds. You may wonder what happens if one of the consumers starts a long task and dies with it only partly done. With our current code once RabbitMQ delivers message to the customer it immediately removes it from memory. In this case, if you kill a worker we will lose the message it was just processing. We'll also lose all the messages that were dispatched to this particular worker but were not yet handled.

But we don't want to lose any tasks. If a worker dies, we'd like the task to be delivered to another worker.

In order to make sure a message is never lost, RabbitMQ supports message acknowledgments. An ack(nowledgement) is sent back from the consumer to tell RabbitMQ that a particular message had been received, processed and that RabbitMQ is free to delete it.

If a consumer dies (its channel is closed, connection is closed, or TCP connection is lost) without sending an ack, RabbitMQ will understand that a message wasn't processed fully and will re-queue it. If there are other consumers online at the same time, it will then quickly redeliver it to another consumer. That way you can be sure that no message is lost, even if the workers occasionally die.

There aren't any message timeouts; RabbitMQ will redeliver the message when the consumer dies. It's fine even if processing a message takes a very, very long time.

Message acknowledgments are turned on by default. In previous examples we explicitly turned them off via the no_ack=True flag. It's time to remove this flag and send a proper acknowledgment from the worker, once we're done with a task.

Using this code we can be sure that even if you kill a worker using CTRL+C while it was processing a message, nothing will be lost. Soon after the worker dies all unacknowledged messages will be redelivered.

我把发送端和接收端分别比作生产者与消费者。生产者发送任务A,消费者接收任务A并处理,处理完后生产者将消息队列中的任务A删除。现在我们遇到了一个问题:如果消费者接收任务A,但在处理的过程中突然宕机了。而此时生产者将消息队列中的任务A删除。实际上任务A并未成功处理完,相当于丢失了任务/消息。为解决这个问题,应使消费者接收任务并成功处理完后发送一个ack到生产者!生产者收到ack后就明白任务A已被成功处理,这时才从消息队列中将任务A删除,如果没有收到ack,就需要把任务A发送给下一个消费者,直到任务A被成功处理。

 

三、消息持久化

前面已经知道,生产者生产数据,消费者再启动是可以接收数据的。

但是,生产者生产数据,然后重启rabbitMQ,消费者是无法接收数据

eg:消息在传输过程中rabbitMQ服务器宕机了,会发现之前的消息队列就不存在了,这时我们就要用到消息持久化,消息持久化会让队列不随着服务器宕机而消失,会永久的保存下去。下面看下关于消息持久化的英文讲解:

We have learned how to make sure that even if the consumer dies, the task isn't lost(by default, if wanna disable  use no_ack=True). But our tasks will still be lost if RabbitMQ server stops.

When RabbitMQ quits or crashes it will forget the queues and messages unless you tell it not to. Two things are required to make sure that messages aren't lost: we need to mark both the queue and messages as durable.

First, we need to make sure that RabbitMQ will never lose our queue. In order to do so, we need to declare it as durable:

      1 channel.queue_declare(queue='hello', durable=True)

Although this command is correct by itself, it won't work in our setup. That's because we've already defined a queue called hello which is not durable. RabbitMQ doesn't allow you to redefine an existing queue with different parameters and will return an error(会曝错) to any program that tries to do that. But there is a quick workaround - let's declare a queue with different name, for exampletask_queue:

      1 channel.queue_declare(queue='task_queue', durable=True)

This queue_declare change needs to be applied to both the producer and consumer code.

At that point we're sure that the task_queue queue won't be lost even if RabbitMQ restarts. Now we need to mark our messages as persistent - by supplying a delivery_mode property with a value 2.

      1 channel.basic_publish(exchange='',
      2                       routing_key="task_queue",
      3                       body=message,
      4                       properties=pika.BasicProperties(
      5                          delivery_mode = 2,      # make message persistent
      6                       ))

上面的英文对消息持久化讲得很好。消息持久化分为两步:

  • 持久化队列。通过代码实现持久化hello队列:channel.queue_declare(queue='hello', durable=True)

  • 持久化队列中的消息。通过代码实现:properties=pika.BasicProperties( delivery_mode = 2, )

这里有个点要注意下:

如果你在代码中已实现持久化hello队列与队列中的消息。那么你重启rabbitMQ后再次运行代码可能会爆错!

因为: RabbitMQ doesn't allow you to redefine an existing queue with different parameters and will return an error.

为了解决这个问题,可以声明一个与重启rabbitMQ之前不同的队列名(queue_name).

 

四、消息公平分发

如果Rabbit只管按顺序把消息发到各个消费者身上,不考虑消费者负载的话,很可能出现,一个机器配置不高的消费者那里堆积了很多消息处理不完,同时配置高的消费者却一直很轻松。为解决此问题,可以在各个消费者端,配置perfetch=1,意思就是告诉RabbitMQ在我这个消费者当前消息还没处理完的时候就不要再给我发新消息了

深入了解python之rabbitMQ使用

 

带消息持久化+公平分发的完整代码

生产者端:

import pika
import sys
 
connection =pika.BlockingConnection(pika.ConnectionParameters(
        host='localhost'))
channel = connection.channel()
 
channel.queue_declare(queue='task_queue', durable=True)  #队列持久化
 
message = ' '.join(sys.argv[1:]) or"Hello World!"
channel.basic_publish(exchange='',
                      routing_key='task_queue',
                      body=message,
                      properties=pika.BasicProperties(
                         delivery_mode = 2, # make message persistent消息持久化
                      ))
print(" [x] Sent %r" % message)
connection.close()


消费者端:

#!/usr/bin/env python
import pika
import time
 
connection =pika.BlockingConnection(pika.ConnectionParameters(
        host='localhost'))
channel = connection.channel()
 
channel.queue_declare(queue='task_queue', durable=True)
print(' [*] Waiting for messages. To exit press CTRL+C')
 
def callback(ch, method, properties, body):
    print(" [x] Received %r" % body)
    time.sleep(body.count(b'.'))
    print(" [x] Done")
    ch.basic_ack(delivery_tag =method.delivery_tag)   
 
channel.basic_qos(prefetch_count=1)
channel.basic_consume(callback,
                      queue='task_queue')
 
channel.start_consuming()

我在运行上面程序时对消费者端里回调函数的一句代码(ch.basic_ack(delivery_tag =method.delivery_tag))十分困惑。这句代码去掉消费者端也能照样收到消息啊。这句代码有毛线用处??

生产者端消息持久后,需要在消费者端加上(ch.basic_ack(delivery_tag =method.delivery_tag)): 保证消息被消费后,消费端发送一个ack,然后服务端从队列删除该消息.

 

五、消息发布与订阅

之前的例子都基本都是1对1的消息发送和接收,即消息只能发送到指定的queue里,但有些时候你想让你的消息被所有的queue收到,类似广播的效果,这时候就要用到exchange了。PS:有兴趣的了解redis的发布与订阅,可以看看我写的博客python之redis。

An exchange is a very simple thing. On one side it receives messages from producers and the other side it pushes them to queues. The exchange must know exactly what to do with a message it receives. Should it be appended to a particular queue? Should it be appended to many queues? Or should it get discarded(丢弃). The rules for that are defined by the exchange type.

宠物商店
宠物商店

目前,PetShop已经从最初的2.0、3.0等版本,发展到了最新的4.0版本。PetShop 4.0使用ASP.NET 2.0技术开发,其中加入了众多新增特性,因此,在性能、代码数量、可扩展性等方面有了重大改善。可以说,学习PetShop 4.0是深入掌握ASP.NET 2.0技术的捷径。本节将引领读者逐步了解PetShop 4.0的方方面面,包括应用程序安装、功能和用户界面简介、解决方案和体系

下载

Exchange在定义的时候是有类型的,以决定到底是哪些Queue符合条件,可以接收消息

 

fanout: 所有bind到此exchange的queue都可以接收消息

direct: 通过routingKey和exchange决定的那个唯一的queue可以接收消息

topic:所有符合routingKey(此时可以是一个表达式)的routingKey所bind的queue可以接收消息

 

表达式符号说明: #代表一个或多个字符,*代表任何字符
          例:#.a会匹配a.a,aa.a,aaa.a等
                *.a会匹配a.a,b.a,c.a等
            注:使用RoutingKey为#,Exchange Type为topic的时候相当于使用fanout

 

下面我分别讲下fanout,direct,topic:

1、fanout

fanout: 所有bind到此exchange的queue都可以接收消息

深入了解python之rabbitMQ使用

send端:

import pika
import sys

connection=pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel=connection.channel()

channel.exchange_declare(exchange='logs',
                      type='fanout')

message=''.join(sys.argv[1:])or"info:HelloWorld!"
channel.basic_publish(exchange='logs',
                      routing_key='',  #fanout的话为空(默认)
                      body=message)
print("[x]Sent%r"%message)
connection.close()


receive端:

import pika

connection=pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel=connection.channel()

channel.exchange_declare(exchange='logs',type='fanout')

#不指定queue名字(为了收广播),rabbit会随机分配一个queue名字,
#exclusive=True会在使用此queue的消费者断开后,自动将queue删除
result=channel.queue_declare(exclusive=True)
queue_name=result.method.queue

#把声明的queue绑定到交换器exchange上
channel.queue_bind(exchange='logs',
                queue=queue_name)

print('[*]Waitingforlogs.ToexitpressCTRL+C')

def callback(ch,method,properties,body):
    print("[x]%r"%body)


channel.basic_consume(callback,
                      queue=queue_name,
                      no_ack=True)

channel.start_consuming()

有两个点要注意下:

  • fanout-广播,send端的routing_key='', #fanout的话为空(默认)

  • receive端有一句代码:result=channel.queue_declare(exclusive=True),作用:不指定queue名字(为了收广播),rabbitMQ会随机分配一个queue名字,exclusive=True会在使用此queue的消费者断开后,自动将queue删除。

 

2、有选择的接收消息(exchange type=direct)

RabbitMQ还支持根据关键字发送,即:队列绑定关键字,发送者将数据根据关键字发送到消息exchange,exchange根据 关键字 判定应该将数据发送至指定队列。

深入了解python之rabbitMQ使用

send端:

import pika
import sys
 
connection =pika.BlockingConnection(pika.ConnectionParameters(
        host='localh'))ost
channel = connection.channel()
 
channel.exchange_declare(exchange='direct_logs',
                         type='direct')
 
severity = sys.argv[1] iflen(sys.argv) > 1 else 'info'
message = ' '.join(sys.argv[2:]) or'Hello World!'
channel.basic_publish(exchange='direct_logs',
                      routing_key=severity, #关键字不为空,告知消息发送到哪里(info,error~)
                      body=message)
print(" [x] Sent %r:%r" % (severity, message))
connection.close()


receive端:

import pika
import sys
 
connection =pika.BlockingConnection(pika.ConnectionParameters(
        host='localhost'))
channel = connection.channel()
 
channel.exchange_declare(exchange='direct_logs',
                         type='direct')
 
result =channel.queue_declare(exclusive=True)
queue_name = result.method.queue
 
severities = sys.argv[1:]
if not severities:
    sys.stderr.write("Usage: %s [info] [warning] [error]\n" %sys.argv[0])
    sys.exit(1)
 
for severity in severities:
    channel.queue_bind(exchange='direct_logs',
                       queue=queue_name,
                       routing_key=severity)
 
print(' [*] Waiting for logs. To exit press CTRL+C')
 
def callback(ch, method, properties, body):
    print(" [x] %r:%r" %(method.routing_key, body))
 
channel.basic_consume(callback,
                      queue=queue_name,
                      no_ack=True)
 
channel.start_consuming()


其实最开始我看代码是一脸懵逼的~ 下面是我在cmd进行测试的截图(配合着截图看会容易理解些),一个send端,两个receive端(先起receive端,再起receive端):

send端:

深入了解python之rabbitMQ使用

receive端-1:

深入了解python之rabbitMQ使用

receive端-2:

深入了解python之rabbitMQ使用

 

3、更细致的消息过滤topic(供参考)

Although using the direct exchange improved our system, it still has limitations - it can't do routing based on multiple criteria.

In our logging system we might want to subscribe to not only logs based on severity, but also based on the source which emitted the log. You might know this concept from the syslog unix tool, which routes logs based on both severity (info/warn/crit...) and facility (auth/cron/kern...).

That would give us a lot of flexibility - we may want to listen to just critical errors coming from 'cron' but also all logs from 'kern'.

感觉我英文水平不高啊~,我对照着垃圾有道翻译,加上自己的理解,大概知道上面在讲什么。

举例: 如果是系统的错误,就把信息发送到A,如果是MySQL的错误,就把信息发送到B。但是对B来说,想实现接收MySQL错误信息,可以用有选择的接收消息(exchange type=direct),让关键字为error就实现了啊!现在B有个需求:不是所有的错误信息都接收,只接收指定的错误。在某种信息再进行过滤,这就是更细致的消息过滤topic。

 

send端:

import pika
import sys
 
connection = pika.BlockingConnection(pika.ConnectionParameters(
        host='localhost'))
channel = connection.channel()
 
channel.exchange_declare(exchange='topic_logs',
                         type='topic')  #类型为topic
 
routing_key = sys.argv[1] if len(sys.argv) > 1 else 'anonymous.info'
message = ' '.join(sys.argv[2:]) or 'Hello World!'
channel.basic_publish(exchange='topic_logs',
                      routing_key=routing_key,
                      body=message)
print(" [x] Sent %r:%r" % (routing_key, message))
connection.close()

receive端:

import pika
import sys
 
connection = pika.BlockingConnection(pika.ConnectionParameters(
        host='localhost'))
channel = connection.channel()
 
channel.exchange_declare(exchange='topic_logs',
                         type='topic')
 
result = channel.queue_declare(exclusive=True)
queue_name = result.method.queue
 
binding_keys = sys.argv[1:]
if not binding_keys:
    sys.stderr.write("Usage: %s [binding_key]...\n" % sys.argv[0])
    sys.exit(1)
 
for binding_key in binding_keys:
    channel.queue_bind(exchange='topic_logs',
                       queue=queue_name,
                       routing_key=binding_key)
 
print(' [*] Waiting for logs. To exit press CTRL+C')
 
def callback(ch, method, properties, body):
    print(" [x] %r:%r" % (method.routing_key, body))
 
channel.basic_consume(callback,
                      queue=queue_name,
                      no_ack=True)
 
channel.start_consuming()

六、RPC(Remote Procedure Call)

RPC的概念可看我百度的(其实就类似我之前做的FTP,我从客户端发一个指令,服务端返回相关信息):

RPC采用客户机/服务器模式。请求程序就是一个客户机,而服务提供程序就是一个服务器。首先,客户机调用进程发送一个有进程参数的调用信息到服务进程,然后等待应答信息。在服务器端,进程保持睡眠状态直到调用信息的到达为止。当一个调用信息到达,服务器获得进程参数,计算结果,发送答复信息,然后等待下一个调用信息,最后,客户端调用进程接收答复信息,获得进程结果,然后调用执行继续进行。

下面重点讲下RPC通信,我刚开始学挺难的,学完之后感觉RPC通信的思想很有启发性,代码的例子写得也很牛!!

深入了解python之rabbitMQ使用

client端发的消息被server端接收后,server端会调用callback函数,执行任务后,还需要把相应的信息发送到client,但是server如何将信息发还给client?如果有多个client连接server,server又怎么知道是要发给哪个client??

RPC-server默认监听rpc_queue.肯定不能把要发给client端的信息发到rpc_queue吧(rpc_queue是监听client端发到server端的数据)。

合理的方案是server端另起一个queue,通过queue将信息返回给对应client。但问题又来了,queue是server端起的,故client端肯定不知道queue_name,连queue_name都不知道,client端接收毛线的数据??

解决方法:

客户端在发送指令的同时告诉服务端:任务执行完后,数据通过某队列返回结果。客户端监听该队列就OK了。

client端:

import pika
import uuid


class FibonacciRpcClient(object):
    def init(self):
        self.connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))

        self.channel = self.connection.channel()
        #随机建立一个queue,为了监听返回的结果
        result = self.channel.queue_declare(exclusive=True)
        self.callback_queue = result.method.queue   ##队列名

        self.channel.basic_consume(self.on_response,  #一接收客户端发来的指令就调用回调函数on_response
                                   no_ack=True,
                                   queue=self.callback_queue)

    def on_response(self, ch, method, props, body):  #回调
        #每条指令执行的速度可能不一样,指令1比指令2先发送,但可能指令2的执行结果比指令1先返回到客户端,
        #此时如果没有下面的判断,客户端就会把指令2的结果误认为指令1执行的结果
        if self.corr_id == props.correlation_id:
            self.response = body

    def call(self, n):
        self.response = None    ##指令执行后返回的消息
        self.corr_id = str(uuid.uuid4())   ##可用来标识指令(顺序)
        self.channel.basic_publish(exchange='',
                                   routing_key='rpc_queue', #client发送指令,发到rpc_queue
                                   properties=pika.BasicProperties(
                                       reply_to=self.callback_queue, #将指令执行结果返回到reply_to队列
                                       correlation_id=self.corr_id,
                                   ),
                                   body=str(n))
        while self.response is None:
            self.connection.process_data_events() #去queue接收数据(不阻塞)
        return int(self.response)


fibonacci_rpc = FibonacciRpcClient()

print(" [x] Requesting fib(30)")
response = fibonacci_rpc.call(30)
print(" [.] Got %r" % response)

server端:

import pika
import time

connection = pika.BlockingConnection(pika.ConnectionParameters(
    host='localhost'))

channel = connection.channel()

channel.queue_declare(queue='rpc_queue')


def fib(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    else:
        return fib(n - 1) + fib(n - 2)


def on_request(ch, method, props, body):
    n = int(body)

    print(" [.] fib(%s)" % n)
    response = fib(n)  #从客户端收到的消息

    ch.basic_publish(exchange='',   ##服务端发送返回的数据到props.reply_to队列(客户端发送指令时声明)
                     routing_key=props.reply_to,  #correlation_id (随机数)每条指令都有随机独立的标识符
                     properties=pika.BasicProperties(correlation_id= \
                                                         props.correlation_id),
                     body=str(response))
    ch.basic_ack(delivery_tag=method.delivery_tag)  #客户端持久化


channel.basic_qos(prefetch_count=1)  #公平分发
channel.basic_consume(on_request,    #一接收到消息就调用on_request
                      queue='rpc_queue')

print(" [x] Awaiting RPC requests")
channel.start_consuming()

相关文章

python速学教程(入门到精通)
python速学教程(入门到精通)

python怎么学习?python怎么入门?python在哪学?python怎么学才快?不用担心,这里为大家提供了python速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
Python 自然语言处理(NLP)基础与实战
Python 自然语言处理(NLP)基础与实战

本专题系统讲解 Python 在自然语言处理(NLP)领域的基础方法与实战应用,涵盖文本预处理(分词、去停用词)、词性标注、命名实体识别、关键词提取、情感分析,以及常用 NLP 库(NLTK、spaCy)的核心用法。通过真实文本案例,帮助学习者掌握 使用 Python 进行文本分析与语言数据处理的完整流程,适用于内容分析、舆情监测与智能文本应用场景。

10

2026.01.27

拼多多赚钱的5种方法 拼多多赚钱的5种方法
拼多多赚钱的5种方法 拼多多赚钱的5种方法

在拼多多上赚钱主要可以通过无货源模式一件代发、精细化运营特色店铺、参与官方高流量活动、利用拼团机制社交裂变,以及成为多多进宝推广员这5种方法实现。核心策略在于通过低成本、高效率的供应链管理与营销,利用平台社交电商红利实现盈利。

109

2026.01.26

edge浏览器怎样设置主页 edge浏览器自定义设置教程
edge浏览器怎样设置主页 edge浏览器自定义设置教程

在Edge浏览器中设置主页,请依次点击右上角“...”图标 > 设置 > 开始、主页和新建标签页。在“Microsoft Edge 启动时”选择“打开以下页面”,点击“添加新页面”并输入网址。若要使用主页按钮,需在“外观”设置中开启“显示主页按钮”并设定网址。

16

2026.01.26

苹果官方查询网站 苹果手机正品激活查询入口
苹果官方查询网站 苹果手机正品激活查询入口

苹果官方查询网站主要通过 checkcoverage.apple.com/cn/zh/ 进行,可用于查询序列号(SN)对应的保修状态、激活日期及技术支持服务。此外,查找丢失设备请使用 iCloud.com/find,购买信息与物流可访问 Apple (中国大陆) 订单状态页面。

136

2026.01.26

npd人格什么意思 npd人格有什么特征
npd人格什么意思 npd人格有什么特征

NPD(Narcissistic Personality Disorder)即自恋型人格障碍,是一种心理健康问题,特点是极度夸大自我重要性、需要过度赞美与关注,同时极度缺乏共情能力,背后常掩藏着低自尊和不安全感,影响人际关系、工作和生活,通常在青少年时期开始显现,需由专业人士诊断。

7

2026.01.26

windows安全中心怎么关闭 windows安全中心怎么执行操作
windows安全中心怎么关闭 windows安全中心怎么执行操作

关闭Windows安全中心(Windows Defender)可通过系统设置暂时关闭,或使用组策略/注册表永久关闭。最简单的方法是:进入设置 > 隐私和安全性 > Windows安全中心 > 病毒和威胁防护 > 管理设置,将实时保护等选项关闭。

6

2026.01.26

2026年春运抢票攻略大全 春运抢票攻略教你三招手【技巧】
2026年春运抢票攻略大全 春运抢票攻略教你三招手【技巧】

铁路12306提供起售时间查询、起售提醒、购票预填、候补购票及误购限时免费退票五项服务,并强调官方渠道唯一性与信息安全。

122

2026.01.26

个人所得税税率表2026 个人所得税率最新税率表
个人所得税税率表2026 个人所得税率最新税率表

以工资薪金所得为例,应纳税额 = 应纳税所得额 × 税率 - 速算扣除数。应纳税所得额 = 月度收入 - 5000 元 - 专项扣除 - 专项附加扣除 - 依法确定的其他扣除。假设某员工月工资 10000 元,专项扣除 1000 元,专项附加扣除 2000 元,当月应纳税所得额为 10000 - 5000 - 1000 - 2000 = 2000 元,对应税率为 3%,速算扣除数为 0,则当月应纳税额为 2000×3% = 60 元。

35

2026.01.26

oppo云服务官网登录入口 oppo云服务登录手机版
oppo云服务官网登录入口 oppo云服务登录手机版

oppo云服务https://cloud.oppo.com/可以在云端安全存储您的照片、视频、联系人、便签等重要数据。当您的手机数据意外丢失或者需要更换手机时,可以随时将这些存储在云端的数据快速恢复到手机中。

121

2026.01.26

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
最新Python教程 从入门到精通
最新Python教程 从入门到精通

共4课时 | 22.3万人学习

Django 教程
Django 教程

共28课时 | 3.6万人学习

SciPy 教程
SciPy 教程

共10课时 | 1.3万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号