python2字典中,如何根据key取出value?字典为:{'tomcat85linux': '/', 'xconfig': '/bin/xconfig-server/config', 'sac': '/bin/web', 'activemq514linux': '/bin/linux-x86-64', 'rabbitmq': '/bin/rabbitmq-auth/config', 'ls': '/script/license', 'xresmgr': '/bin/xresmgr-rms/config', 'loganalysis': '/bin/loges', 'xjob': '/bin/xjob-server/config', 'xdictionary': '/bin/xdictionary-dds/config'}
时间: 2023-12-07 14:04:01 浏览: 184
CH4-Porting-Linux-Kernel.rar_Linux/Unix编程_Unix_Linux_
可以使用字典的get()方法根据key取出value,如下所示:
```
my_dict = {'tomcat85linux': '/', 'xconfig': '/bin/xconfig-server/config', 'sac': '/bin/web', 'activemq514linux': '/bin/linux-x86-64', 'rabbitmq': '/bin/rabbitmq-auth/config', 'ls': '/script/license', 'xresmgr': '/bin/xresmgr-rms/config', 'loganalysis': '/bin/loges', 'xjob': '/bin/xjob-server/config', 'xdictionary': '/bin/xdictionary-dds/config'}
value = my_dict.get('tomcat85linux')
print(value)
```
输出结果为:
```
/
```
阅读全文