我找不到如何在PHP中编写空的Python结构/字典.当我在PHP中编写"{}"时,它给了我一个错误.Python字典的等效php编程结构是什么?
在php中,有关联数组,类似于字典。尝试看一下文档:http : //php.net/manual/en/language.types.array.php
在python中,您这样声明一个空字典:
m_dictionary = {} #empty dictionary
m_dictionary["key"] = "value" #adding a couple key-value
print(m_dictionary)
Run Code Online (Sandbox Code Playgroud)
在php中执行相同操作的方式与python的方式非常相似:
$m_assoc_array = array();//associative array
$m_assoc_array["key"] = "value";//adding a couple key-value
print_r($m_assoc_array);
Run Code Online (Sandbox Code Playgroud)
在 PHP Python 中dict和list是相同的array():
$arr = array();
$arr['a'] = 1;
print_r($arr['a']);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3794 次 |
| 最近记录: |