小编fra*_*ows的帖子

如何在Python中循环JSON

我无法弄清楚如何循环一个深度超过1级的JSON对象.对象是:

{
  "data":[
    {
      "id":"251228454889939/insights/page_fan_adds_unique/day",
      "name":"page_fan_adds_unique",
      "period":"day",
      "values":[
        {
          "value":9,
          "end_time":"2012-05-29T07:00:00+0000"
        },
        {
          "value":5,
          "end_time":"2012-05-30T07:00:00+0000"
        }
      ],
      "title":"Daily New Likes",
      "description":"Daily The number of new people who have liked your Page (Unique Users)"
    },
    {
      "id":"251228454889939/insights/page_fan_adds/day",
      "name":"page_fan_adds",
      "period":"day",
      "values":[
        {
          "value":9,
          "end_time":"2012-05-29T07:00:00+0000"
        },
        {
          "value":5,
          "end_time":"2012-05-30T07:00:00+0000"
        }
      ],
      "title":"Daily New Likes",
      "description":"Daily The number of new people who have liked your Page (Total Count)"
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

码:

def parseJsonData(data):
    output_json = json.loads(data)
    for i in output_json:
        print i
        for …
Run Code Online (Sandbox Code Playgroud)

python json loops

1
推荐指数
1
解决办法
3万
查看次数

jQuery .get not working

每当.information单击该元素时,我都会运行以下代码.我想在单击时将aboutMe.html文档添加到#text元素.information:

$(".information").click( function() {
    $.get("aboutMe.html"), function(data){
        $("#text").html(data);
}});
Run Code Online (Sandbox Code Playgroud)

由于某种原因,.information单击时文档不会添加到页面中.

javascript jquery get

1
推荐指数
1
解决办法
8109
查看次数

使用jQuery动态添加按钮

我试图动态添加一个按钮 - 第一个按钮有效但其他按钮无效.我以前使用过该live函数,但jQuery 1.9.1删除了该函数.我该怎么做才能让新添加的按钮起作用?

HTML代码:

<div class="take">
    <p>this is the para</p>
    <button class="test">copy</button>
</div>
Run Code Online (Sandbox Code Playgroud)

jQuery代码:

$('.test').on('click', function() {
    var a = $(this).parent();
    new.clone().insertAfter(a);
})
Run Code Online (Sandbox Code Playgroud)

这是jsfiddle.

html css jquery

0
推荐指数
1
解决办法
1241
查看次数

使用jQuery检查街道地址的最小字符

我有一个 jQuery 函数来检查邮政编码中的数字字符。我还需要检查街道地址的最少字符数 (10)。

function paymentStep1(){

jQuerychk = jQuery.noConflict();
var numbers = /^[0-9]+$/; 
var zip = jQuerychk("input#id_billing_detail_postcode").val();  
if (zip.match(numbers))  {
document.getElementById("errormsssgen").innerHTML = '';
}else{      
    document.getElementById("errormsssgen").innerHTML = "ZIP code must have numeric characters only."
    return false;
}
Run Code Online (Sandbox Code Playgroud)

jquery

0
推荐指数
1
解决办法
223
查看次数

如何使用JavaScript检查打印机是否没有纸张

我需要从网上打印多个页面.我使用JavaScript来打印页面.我们如何检查打印机是否有使用JavaScript的纸张?

javascript jquery

0
推荐指数
1
解决办法
278
查看次数

正则表达式删除花括号中的单词

我正在寻找一种方法从另一个子串中删除大括号内的任何子串.

例如:

  • 如果我有字符串"The cat is {not} mine",我想要一个返回的函数"The cat is mine";
  • 如果我有"the glass was broken {by the dog}",我想要一个返回的功能"The glass was broken "

我已经读过可以在replace函数中使用正则表达式,但我不知道如何使用它.

javascript regex string replace

0
推荐指数
1
解决办法
1094
查看次数

标签 统计

jquery ×4

javascript ×3

css ×1

get ×1

html ×1

json ×1

loops ×1

python ×1

regex ×1

replace ×1

string ×1