Getting "ValueError: need more than 1 value to unpack" while trying to read a value from dictionary in python

Prahallad Achar acharbly at gmail.com
Thu Feb 15 06:17:08 EST 2018


IPv4 address configured by DHCP

It doesn't find key and value for above string.

Solution.. Use one complete string per  line

On 15 Feb 2018 4:41 pm, "Sum J" <sjsumitj at gmail.com> wrote:

Below is my code. Here I want to read the "ip address" from s


 s= '''
    Power On Enabled = On
    State: connected
    Radio Module: Unknown
    noise: -097
    signalStrength: -046
    ip address: 192.168.75.147
    subnet mask: 255.255.255.0
    IPv4 address configured by DHCP
    Mac Addr: ac:e2:d3:32:00:5a
    Mode: infrastrastructure
    ssid: Cloudlab
    Channel: 1
    Regulatory: World Safe
    Authencation: WPA2/PSK
    Encryption:  AES or TKIP
    '''

   s = s.replace("=",":")
   # s = s.strip()
   print s

  d = {}
  for i in s:
     key, val = i.split(":")
     d[key] = val.strip()

  print d
  print d["ip address"]


Getting below error :
<module> key, val = i.split(":")
ValueError: need more than 1 value to unpack
--
https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list