Domain Name: dada.com,
Registry Domain ID: 102993_DOMAIN_COM-VRSN,
Registrar WHOIS Server: whois.pairNIC.com,
Registrar URL: https://www.pairNIC.com,
Updated Date: 2014-02-03T19:00:24+0000Z,
Creation Date: 1995-03-04T05:00:00+0000Z,
Registrar Registration Expiration Date: 2018-03-05T05:00:00+0000Z,
Registrar: pairNIC INC,
Registrar IANA ID: 99,
Registrar Abuse Contact Email: [email protected],
Registrar Abuse Contact Phone: +1.8887247642,
Domain Status: clientDeleteProhibited,
Domain Status: clientTransferProhibited,
Domain Status: clientUpdateProhibited,
Registry Registrant ID: ,
Registrant Name: Juan-Carlos Sobrino,
Registrant Organization: ,
Registrant Street: 47 Saint Mark's Place ,
Registrant City: New York,
Registrant State/Province: NY,
Registrant Postal Code: 10003,
Registrant Country: US,
Registrant Phone: +1.6465551234,
Registrant Phone Ext:,
就类似这样的数据,有的冒号后面还是空的值。。。怎么解决。。。。求助
1
silentoy 2017-04-11 11:31:14 +08:00 1
```php
$data = explode("\n", $str); $res = array(); foreach ($data as $item) { list($key, $value) = explode(":", $item); $res[trim($key)] = trim($value, ' ,'); } var_dump($res); ``` |
2
kghch 2017-04-11 11:39:19 +08:00
lines = data.split(',')
res = {} for line in lines: line= line.split(':') k = line[0] v = '' if len(line) > 1: v = line[1] res[k] = v print res |
4
kghch 2017-04-11 12:55:47 +08:00
#2 ,格式丢了,不好意思。
|
5
nfroot 2017-04-11 14:03:06 +08:00
php 的数组 key 还能用空格啊
|
6
wangjie 2017-04-11 14:38:16 +08:00
let a={}
data.split(',') .map((t)=>{ let l=t.split(':') a[l[0]]=l[1] }) console.log(a) |
7
Tyanboot 2017-04-11 23:44:39 +08:00 via Android
…楼上用 Python 和 JS 回答的是在想啥。
|