This commit is contained in:
2022-11-21 17:23:21 +01:00
parent db7de0a6e8
commit 8657075f55
5 changed files with 110 additions and 2 deletions

41
Montag/dict.py Normal file
View File

@@ -0,0 +1,41 @@
#! /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)