0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

プログラミング技術を使って、自分ができることは

Last updated at Posted at 2020-10-26

技術を何につかうか考えると、コード演習だけでは見えていませんでした。

現時点で、わかったことが2つあります。
1、ディクショナリ型のデータを使って、情報を管理する。
2、jsonは、Webアプリケーションからデータ取得に使われる。
3、Pythonで、jsonをインポートし、従業員情報の管理をする。例)idや名前など

import json
j = {
    "employee":
        [
            {"id": 111,"name": "John"},
            {"id": 222,"name": "Elle"}
        ]
}

print(j)
a = json.dumps(j)
print(json.dumps(a))
with open('test.json','w') as f:
    json.dump(j,f)

with open('test.json','r') as f:
    print(json.load(f)) #ファイル内で、出力したファイルの読み書きを行う。

エイジャックスを使ったページの要素の取得です。

該当するソースコード

 $.ajax({
    url: "./information.json",
    dataType: "json"
  })
  .done(function(json){

    var idx = 0; 
    var $info = $(".info__list .item");
    $info.find("time").text(json[idx].date);
    $info.find("p").text(json[idx].value);

    setInterval(function(){
      if(idx === json.length -1){
        idx = 0;
      } else {
        idx = idx + 1;
      }
      $info.css("opacity",0);

      setTimeout(function(){
        $info.find("time").text(json[idx].date);
        $info.find("p").text(json[idx].value);
        $info.css("opacity",1);
      },500);

    },5000)

  });

最後にデータの取得について

Webページの情報の取得をrequestsというサードパーティーできるようです。
JavaScriptの情報の取得コードについても調べてみます。

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?