43 lines
741 B
Python
Executable File
43 lines
741 B
Python
Executable File
#! /usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
mydict = {}
|
|
mydict['hostname'] = "notebook43", "notebook2"
|
|
mydict['address'] = '192.168.1.243'
|
|
mydict['OS'] = 'Debian 5.10.149-2'
|
|
mydict['ssd'] = True
|
|
mydict['ramsize'] = 16
|
|
|
|
#####mydict['hostname'].append("notebook3")
|
|
|
|
print(mydict)
|
|
|
|
for key in mydict.keys():
|
|
print(key, '=', mydict[key])
|
|
|
|
print("-"*50)
|
|
|
|
for value in mydict.values():
|
|
print(value)
|
|
print("-"*50)
|
|
#Better
|
|
for key, value in mydict.items():
|
|
print(key, '=', value )
|
|
|
|
print("-"*50)
|
|
|
|
print(mydict.get('OS', "default_value"))
|
|
|
|
print("-"*50)
|
|
|
|
for test in mydict.get('hostname'):
|
|
print(test)
|
|
|
|
print("-"*50)
|
|
pop_value = mydict.pop("hostname")
|
|
print(pop_value)
|
|
|
|
print("-"*50)
|
|
key, value = mydict.popitem()
|
|
print(mydict)
|
|
|