2018-09-03day11 作业

2018-09-04  本文已影响0人  xaidc
  1. 提取data.json中的数据,将每条数据中的name、text、love和comment信息。并且保存到另外一个json文件中
import json
data2 = []

with open('./files/data.json','r',encoding='utf-8') as f:
    content = json.load(f)
    print(content)

for item in content["data"][:]:
    data1 = {}
    data1["name"] = item["name"]
    data1["text"] = item["text"]
    data1["comment"] = item["comment"]
    data1["love"] = item["love"]
    data2.append(data1)


with open("./files/newdata.json",'w',encoding='utf-8') as ff:
    json.dump(data2,ff,ensure_ascii=False,indent=2)
    print(data2)
输出结果:
[
  {
    "name": "龘靐龗齾齉爩虌麷灩韊",
    "text": "闲来无事看看直播,点开个漂亮小姐姐……我特么………… ​​​",
    "comment": "84",
    "love": "557"
  },
  {
    "name": "一叶珈蓝",
    "text": "你的房子失火了,你只能选择一样东西,你会救什么?",
    "comment": "134",
    "love": "242"
  },
  {
    "name": "逍遥帮主阿紫",
    "text": "遇到这种情况,你会怎么办?",
    "comment": "152",
    "love": "301"
  },
  {
    "name": "拽拽快乐视频",
    "text": "一组超赞的肩颈按摩教程!上班上学总是久坐,经常会感到肩膀酸疼、颈椎僵硬。这组小动作,可以帮你缓解肩颈疼痛,保护肩颈健康,远离颈椎病!转存!",
    "comment": "32",
    "love": "277"
  },
  {
    "name": "为你改变love",
    "text": "粉丝为赵丽颖连续签到405天,却因男友生日断签,愤怒与男友分手!",
    "comment": "488",
    "love": "1043"
  },
  {
    "name": "吐嚎Video",
    "text": "1套按摩操,专治颈椎病,治1个好1个,颈椎不好的快存!",
    "comment": "103",
    "love": "3390"
  },
  {
    "name": "黑皮呲呲水",
    "text": "挑西瓜速成秘籍",
    "comment": "71",
    "love": "266"
  },
  {
    "name": "斜眼看你笑",
    "text": "全程都是梗啊,郭德纲和于谦的搞笑相声《恋爱进行曲》,肚子笑的都疼了",
    "comment": "79",
    "love": "714"
  },
  {
    "name": "別敷衍_涐",
    "text": "男,身高182,95年的。有房,每个月有房贷,有车。人长的还算行,不丑也不帅的那种,月收入一万。工作原因,很少接触女孩子,所以单到现在。想找个男朋友,一起过日子的那种!",
    "comment": "17",
    "love": "130"
  },
  {
    "name": "我爱你小酒窝~",
    "text": "假期过后上班时的你,简直一摸一样!",
    "comment": "92",
    "love": "1732"
  },
  {
    "name": "鲁尼古拉斯",
    "text": "这么漂亮的眼睛见过没有?仿佛看到两颗璀璨的星辰",
    "comment": "71",
    "love": "358"
  },
  {
    "name": "内涵神评湿",
    "text": "排骨切块,洗净,冷水加葱姜料酒焯水,打去浮沫,小火20分钟,冲洗干净,控干水分,拍淀粉,七成油温炸制金黄备用。      锅烧少许油,半勺糖,半勺醋,适量盐,半勺番茄酱,熬制粘稠,少量勾芡,下入排骨翻炒均匀,撒芝麻,完成。",
    "comment": "3",
    "love": "105"
  },
  {
    "name": "搞笑内涵侠",
    "text": "割完蛋蛋,一脸生无可恋的表情,好可怜啊",
    "comment": "139",
    "love": "943"
  },
  {
    "name": "全球领先在线视频",
    "text": "拳皇98中韩对决,赏心悦目的操作",
    "comment": "124",
    "love": "710"
  },
  {
    "name": "神马情况这是",
    "text": "“我爱你”的经典表达方式 :周星驰:我养你啊!苏轼:不思量,自难忘。黄伟文:余生请你指教。王家卫:那一刻,我很暖。夏目漱石:今晚月色真美。张学友:很想带你去吹吹风。玛格丽特:我在床上,饭在锅里。范仲淹:酒入愁肠,化作相思泪。李白:郎骑竹马来,绕床弄青梅。张爱玲:你还不来,我怎敢老去。钱武肃王:陌上花开,可缓缓归矣。方文山:天青色等烟雨,而我在等你。刀郎:自你离开以后,从此就丢了温柔。元稹:曾经沧海难为水,除去巫山不是云。张国荣:就让我陪你唱一辈子戏,不行吗?王小波:你好哇,李银河,见到你真高兴。李之仪:只愿君心似我心,定不负相思意。柳永:衣带渐宽终不悔,为伊消得人憔悴。林夕:你是我这一生等了半世未拆的礼物。李商隐:直道相思了无益,未妨惆怅是清狂。仓央嘉措:世间安得双全法,不负如来不负卿。冯唐:春水初生,春林初盛,春风十里,不如你。纳兰性德:凄凉别后两应同,最是不胜清怨月明中。鲁迅:我爱子君,仗着她逃出这寂静和空虚。卓别林:我可以选择让你看见,也可以选择坚持不让你看见。李宗盛:春风再美也比不上你的笑,没见过你的人不会明了。顾城:草在结它的种子,风在摇它的叶子,我们站着,不说话,就十分美好。沈从文:我行过许多地方的桥,看过许多次数的云,喝过许多种类的酒, 却只爱过一个正当最好年龄的人。所以,你的“我爱你”怎么表达呢?",
    "comment": "160",
    "love": "1370"
  },
  {
    "name": "胡成功导演",
    "text": "有梦想,有责任!",
    "comment": "19",
    "love": "238"
  },
  {
    "name": "趣图V",
    "text": "完全诠释了,还没开始就已经结束了",
    "comment": "10",
    "love": "145"
  },
  {
    "name": "白头人间_",
    "text": "老物件了,小时候的回忆啊。【我们都怀旧/活动精选】",
    "comment": "224",
    "love": "817"
  },
  {
    "name": "我爱你小酒窝~",
    "text": "金毛:让你天天狗肉汤,狗肉汤,我不要面子的啊",
    "comment": "20",
    "love": "428"
  },
  {
    "name": "终结者绎",
    "text": "兄弟,你是不是对帅有什么误解?",
    "comment": "383",
    "love": "1197"
  }
]
  1. 统计data.json中comment数量超过1000的个数
    注意这里的data2列表是第一题的列表
count = 0
for item in data2:
    if int(item["comment"]) > 1000:
        count +=1
print(count)
输出结果:
0
  1. 将data.json文件中所有点赞数(love)对应的值超出1000的用k来表示, 例如1000修改为1k, 1345修改为1.3k
with open("./files/data.json",'r',encoding='utf-8') as f:
    content = json.load(f)
for item in content["data"][:]:
    if int(item["love"]) >= 1000:
        item["love"]= str((int(item["love"])//100)/10) + 'k'
with open('./files/newdata1.json','w',encoding='utf-8') as ff:
    json.dump(content,ff,ensure_ascii=False,indent=2)
print(content)
输出结果:
{
  "code": 200,
  "data": [
    {
      "bimageuri": "",
      "bookmark": "12",
      "cache_version": 2,
      "cai": "57",
      "cdn_img": "http://wimg.spriteapp.cn/ugc/2018/06/11/5b1d9b15aeb0b_1.jpg",
      "comment": "84",
      "create_time": null,
      "created_at": "2018-06-12 06:24:01",
      "ding": "557",
      "favourite": "12",
      "hate": "57",
      "height": "876",
      "image_small": null,
      "image0": "http://wimg.spriteapp.cn/ugc/2018/06/11/5b1d9b15aeb0b_1.jpg",
      "image1": "http://wimg.spriteapp.cn/ugc/2018/06/11/5b1d9b15aeb0b_1.jpg",
      "image2": "http://wimg.spriteapp.cn/ugc/2018/06/11/5b1d9b15aeb0b_1.jpg",
      "is_gif": false,
      "love": "557",
      "name": "龘靐龗齾齉爩虌麷灩韊",
      "original_pid": "0",
      "passtime": "2018-06-12 06:24:01",
      "playcount": null,
      "playfcount": null,
      "profile_image": "http://wimg.spriteapp.cn/profile/large/2016/10/07/57f7b339ed872_mini.jpg",
      "repost": "23",
      "screen_name": "龘靐龗齾齉爩虌麷灩韊",
      "status": "4",
      "t": 1528755841,
      "tag": "",
      "text": "闲来无事看看直播,点开个漂亮小姐姐……我特么………… ​​​",
      "theme_id": "58240",
      "theme_name": "搞笑图片",
      "theme_type": "1",
      "themes": null,
      "top_cmt": null,
      "type": "10",
      "user_id": "13943553",
      "videotime": 0,
      "videouri": "",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "440"
    },
    {
      "bimageuri": "",
      "bookmark": "3",
      "cache_version": 2,
      "cai": "31",
      "cdn_img": "http://wimg.spriteapp.cn/ugc/2018/08/06/5b67bdb075417_1.jpg",
      "comment": "134",
      "create_time": null,
      "created_at": "2018-08-07 07:12:02",
      "ding": "242",
      "favourite": "3",
      "hate": "31",
      "height": "333",
      "image_small": null,
      "image0": "http://wimg.spriteapp.cn/ugc/2018/08/06/5b67bdb075417_1.jpg",
      "image1": "http://wimg.spriteapp.cn/ugc/2018/08/06/5b67bdb075417_1.jpg",
      "image2": "http://wimg.spriteapp.cn/ugc/2018/08/06/5b67bdb075417_1.jpg",
      "is_gif": false,
      "love": "242",
      "name": "一叶珈蓝",
      "original_pid": "0",
      "passtime": "2018-08-07 07:12:02",
      "playcount": null,
      "playfcount": null,
      "profile_image": "http://wimg.spriteapp.cn/profile/large/2018/07/29/5b5d8d37ebac4_mini.jpg",
      "repost": "2",
      "screen_name": "一叶珈蓝",
      "status": "4",
      "t": 1533597122,
      "tag": "",
      "text": "你的房子失火了,你只能选择一样东西,你会救什么?",
      "theme_id": "44289",
      "theme_name": "互动区",
      "theme_type": "1",
      "themes": null,
      "top_cmt": null,
      "type": "10",
      "user_id": "22675409",
      "videotime": 0,
      "videouri": "",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "671"
    },
    {
      "bimageuri": "http://wimg.spriteapp.cn/picture/2018/0806/65c7599c-9904-11e8-a53c-0026b938a8ac_wpd.jpg",
      "bookmark": "2",
      "cache_version": 2,
      "cai": "26",
      "cdn_img": "http://wimg.spriteapp.cn/picture/2018/0806/65c7599c-9904-11e8-a53c-0026b938a8ac_wpd.jpg",
      "comment": "152",
      "create_time": null,
      "created_at": "2018-08-07 09:40:02",
      "ding": "301",
      "favourite": "2",
      "hate": "26",
      "height": "844",
      "image_small": "http://wimg.spriteapp.cn/picture/2018/0806/65c7599c-9904-11e8-a53c-0026b938a8ac_wpd.jpg",
      "image0": "http://wimg.spriteapp.cn/picture/2018/0806/65c7599c-9904-11e8-a53c-0026b938a8ac_wpd.jpg",
      "image1": "http://wimg.spriteapp.cn/picture/2018/0806/65c7599c-9904-11e8-a53c-0026b938a8ac_wpd.jpg",
      "image2": "http://wimg.spriteapp.cn/picture/2018/0806/65c7599c-9904-11e8-a53c-0026b938a8ac_wpd.jpg",
      "is_gif": false,
      "love": "301",
      "name": "逍遥帮主阿紫",
      "original_pid": "0",
      "passtime": "2018-08-07 09:40:02",
      "playcount": "32559",
      "playfcount": "10447",
      "profile_image": "http://wimg.spriteapp.cn/profile/large/2018/07/20/5b51756073006_mini.jpg",
      "repost": "8",
      "screen_name": "逍遥帮主阿紫",
      "status": "4",
      "t": 1533606002,
      "tag": "",
      "text": "遇到这种情况,你会怎么办?",
      "theme_id": "55163",
      "theme_name": "主版块",
      "theme_type": "1",
      "themes": null,
      "top_cmt": null,
      "type": "41",
      "user_id": "22714206",
      "videotime": 15,
      "videouri": "http://wvideo.spriteapp.cn/video/2018/0806/65c7599c-9904-11e8-a53c-0026b938a8ac_wpd.mp4",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "480"
    },
    {
      "bimageuri": "http://wimg.spriteapp.cn/picture/2018/0423/27706874_491.jpg",
      "bookmark": "178",
      "cache_version": 2,
      "cai": "7",
      "cdn_img": "http://wimg.spriteapp.cn/picture/2018/0423/27706874_491.jpg",
      "comment": "32",
      "create_time": null,
      "created_at": "2018-04-26 14:39:02",
      "ding": "277",
      "favourite": "178",
      "hate": "7",
      "height": "480",
      "image_small": "http://wimg.spriteapp.cn/picture/2018/0423/27706874_491.jpg",
      "image0": "http://wimg.spriteapp.cn/picture/2018/0423/27706874_491.jpg",
      "image1": "http://wimg.spriteapp.cn/picture/2018/0423/27706874_491.jpg",
      "image2": "http://wimg.spriteapp.cn/picture/2018/0423/27706874_491.jpg",
      "is_gif": false,
      "love": "277",
      "name": "拽拽快乐视频",
      "original_pid": "0",
      "passtime": "2018-04-26 14:39:02",
      "playcount": "4691",
      "playfcount": "123",
      "profile_image": "http://wimg.spriteapp.cn/profile/large/2017/10/10/59dca3c409d5d_mini.jpg",
      "repost": "78",
      "screen_name": "拽拽快乐视频",
      "status": "4",
      "t": 1524724742,
      "tag": "",
      "text": "一组超赞的肩颈按摩教程!上班上学总是久坐,经常会感到肩膀酸疼、颈椎僵硬。这组小动作,可以帮你缓解肩颈疼痛,保护肩颈健康,远离颈椎病!转存!",
      "theme_id": "747",
      "theme_name": "健康养生",
      "theme_type": "1",
      "themes": null,
      "top_cmt": null,
      "type": "41",
      "user_id": "21161412",
      "videotime": 125,
      "videouri": "http://wvideo.spriteapp.cn/video/2018/0423/eabae7ca-46db-11e8-9e8e-1866daeb0df1_wpd.mp4",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "480"
    },
    {
      "bimageuri": "",
      "bookmark": "14",
      "cache_version": 2,
      "cai": "289",
      "cdn_img": "http://wimg.spriteapp.cn/ugc/2017/09/05/59aea3d8a5e87_1.jpg",
      "comment": "488",
      "create_time": null,
      "created_at": "2017-09-06 16:46:01",
      "ding": "1043",
      "favourite": "14",
      "hate": "289",
      "height": "5691",
      "image_small": null,
      "image0": "http://wimg.spriteapp.cn/ugc/2017/09/05/59aea3d8a5e87_1.jpg",
      "image1": "http://wimg.spriteapp.cn/ugc/2017/09/05/59aea3d8a5e87_1.jpg",
      "image2": "http://wimg.spriteapp.cn/ugc/2017/09/05/59aea3d8a5e87_1.jpg",
      "is_gif": false,
      "love": "1.0k",
      "name": "为你改变love",
      "original_pid": "0",
      "passtime": "2017-09-06 16:46:01",
      "playcount": null,
      "playfcount": null,
      "profile_image": "http://wimg.spriteapp.cn/profile/large/2016/11/15/582b24d33dd0b_mini.jpg",
      "repost": "16",
      "screen_name": "为你改变love",
      "status": "4",
      "t": 1504687561,
      "tag": "",
      "text": "粉丝为赵丽颖连续签到405天,却因男友生日断签,愤怒与男友分手!",
      "theme_id": "1381",
      "theme_name": "娱乐八卦",
      "theme_type": "1",
      "themes": null,
      "top_cmt": null,
      "type": "10",
      "user_id": "18996959",
      "videotime": 0,
      "videouri": "",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "576"
    },
    {
      "bimageuri": "http://wimg.spriteapp.cn/picture/2017/1011/59dcfa0fc2b31__b_39.jpg",
      "bookmark": "2213",
      "cache_version": 2,
      "cai": "63",
      "cdn_img": "http://wimg.spriteapp.cn/picture/2017/1011/59dcfa0fc2b31__b_39.jpg",
      "comment": "103",
      "create_time": null,
      "created_at": "2017-10-12 14:43:02",
      "ding": "3390",
      "favourite": "2213",
      "hate": "63",
      "height": "600",
      "image_small": "http://wimg.spriteapp.cn/picture/2017/1011/59dcfa0fc2b31__b_39.jpg",
      "image0": "http://wimg.spriteapp.cn/picture/2017/1011/59dcfa0fc2b31__b_39.jpg",
      "image1": "http://wimg.spriteapp.cn/picture/2017/1011/59dcfa0fc2b31__b_39.jpg",
      "image2": "http://wimg.spriteapp.cn/picture/2017/1011/59dcfa0fc2b31__b_39.jpg",
      "is_gif": false,
      "love": "3.3k",
      "name": "吐嚎Video",
      "original_pid": "0",
      "passtime": "2017-10-12 14:43:02",
      "playcount": "38631",
      "playfcount": "1909",
      "profile_image": "http://wimg.spriteapp.cn/profile/large/2017/08/12/598f1e1119252_mini.jpg",
      "repost": "1467",
      "screen_name": "吐嚎Video",
      "status": "4",
      "t": 1507790582,
      "tag": "",
      "text": "1套按摩操,专治颈椎病,治1个好1个,颈椎不好的快存!",
      "theme_id": "58773",
      "theme_name": "安全与健康",
      "theme_type": "1",
      "themes": null,
      "top_cmt": null,
      "type": "41",
      "user_id": "19414702",
      "videotime": 213,
      "videouri": "http://wvideo.spriteapp.cn/video/2017/1011/59dcfa10159ec_wpd.mp4",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "1066"
    },
    {
      "bimageuri": "",
      "bookmark": "10",
      "cache_version": 2,
      "cai": "32",
      "cdn_img": "http://wimg.spriteapp.cn/ugc/2018/06/18/5b27cf614f34e_1.jpg",
      "comment": "71",
      "create_time": null,
      "created_at": "2018-06-19 22:36:02",
      "ding": "266",
      "favourite": "10",
      "hate": "32",
      "height": "4348",
      "image_small": null,
      "image0": "http://wimg.spriteapp.cn/ugc/2018/06/18/5b27cf614f34e_1.jpg",
      "image1": "http://wimg.spriteapp.cn/ugc/2018/06/18/5b27cf614f34e_1.jpg",
      "image2": "http://wimg.spriteapp.cn/ugc/2018/06/18/5b27cf614f34e_1.jpg",
      "is_gif": false,
      "love": "266",
      "name": "黑皮呲呲水",
      "original_pid": "0",
      "passtime": "2018-06-19 22:36:02",
      "playcount": null,
      "playfcount": null,
      "profile_image": "http://wimg.spriteapp.cn/profile/large/2018/05/06/5aeeaafd46093_mini.jpg",
      "repost": "9",
      "screen_name": "黑皮呲呲水",
      "status": "4",
      "t": 1529418962,
      "tag": "",
      "text": "挑西瓜速成秘籍",
      "theme_id": "58240",
      "theme_name": "搞笑图片",
      "theme_type": "1",
      "themes": null,
      "top_cmt": null,
      "type": "10",
      "user_id": "20208094",
      "videotime": 0,
      "videouri": "",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "499"
    },
    {
      "bimageuri": "http://wimg.spriteapp.cn/picture/2018/0523/27984331_418.jpg",
      "bookmark": "316",
      "cache_version": 2,
      "cai": "34",
      "cdn_img": "http://wimg.spriteapp.cn/picture/2018/0523/27984331_418.jpg",
      "comment": "79",
      "create_time": null,
      "created_at": "2018-06-03 12:50:03",
      "ding": "714",
      "favourite": "316",
      "hate": "34",
      "height": "360",
      "image_small": "http://wimg.spriteapp.cn/picture/2018/0523/27984331_418.jpg",
      "image0": "http://wimg.spriteapp.cn/picture/2018/0523/27984331_418.jpg",
      "image1": "http://wimg.spriteapp.cn/picture/2018/0523/27984331_418.jpg",
      "image2": "http://wimg.spriteapp.cn/picture/2018/0523/27984331_418.jpg",
      "is_gif": false,
      "love": "714",
      "name": "斜眼看你笑",
      "original_pid": "0",
      "passtime": "2018-06-03 12:50:03",
      "playcount": "26476",
      "playfcount": "2834",
      "profile_image": "http://wimg.spriteapp.cn/profile/20170512104036.jpg",
      "repost": "49",
      "screen_name": "斜眼看你笑",
      "status": "4",
      "t": 1528001403,
      "tag": "",
      "text": "全程都是梗啊,郭德纲和于谦的搞笑相声《恋爱进行曲》,肚子笑的都疼了",
      "theme_id": "0",
      "theme_name": "",
      "theme_type": "0",
      "themes": null,
      "top_cmt": null,
      "type": "41",
      "user_id": "20746603",
      "videotime": 904,
      "videouri": "http://wvideo.spriteapp.cn/video/2018/0523/a22085fe5e5711e89b0a842b2b4c75ab_wpd.mp4",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "640"
    },
    {
      "bimageuri": "",
      "bookmark": "0",
      "cache_version": 2,
      "cai": "12",
      "cdn_img": null,
      "comment": "17",
      "create_time": null,
      "created_at": "2018-04-09 09:11:49",
      "ding": "130",
      "favourite": "0",
      "hate": "12",
      "height": "0",
      "image_small": null,
      "image0": null,
      "image1": null,
      "image2": null,
      "is_gif": null,
      "love": "130",
      "name": "別敷衍_涐",
      "original_pid": "0",
      "passtime": "2018-04-09 09:11:49",
      "playcount": null,
      "playfcount": null,
      "profile_image": "http://wimg.spriteapp.cn/profile/large/2016/10/21/5809b87b20383_mini.jpg",
      "repost": "1",
      "screen_name": "別敷衍_涐",
      "status": "4",
      "t": 1523236309,
      "tag": "",
      "text": "男,身高182,95年的。有房,每个月有房贷,有车。人长的还算行,不丑也不帅的那种,月收入一万。工作原因,很少接触女孩子,所以单到现在。想找个男朋友,一起过日子的那种!",
      "theme_id": "10745",
      "theme_name": "搞笑段子",
      "theme_type": "1",
      "themes": null,
      "top_cmt": null,
      "type": "29",
      "user_id": "19535993",
      "videotime": 0,
      "videouri": "",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "0"
    },
    {
      "bimageuri": "http://wimg.spriteapp.cn/picture/2017/1002/59d1fd9211413__b.jpg",
      "bookmark": "127",
      "cache_version": 2,
      "cai": "61",
      "cdn_img": "http://wimg.spriteapp.cn/picture/2017/1002/59d1fd9211413__b.jpg",
      "comment": "92",
      "create_time": null,
      "created_at": "2017-10-09 14:15:01",
      "ding": "1732",
      "favourite": "127",
      "hate": "61",
      "height": "854",
      "image_small": "http://wimg.spriteapp.cn/picture/2017/1002/59d1fd9211413__b.jpg",
      "image0": "http://wimg.spriteapp.cn/picture/2017/1002/59d1fd9211413__b.jpg",
      "image1": "http://wimg.spriteapp.cn/picture/2017/1002/59d1fd9211413__b.jpg",
      "image2": "http://wimg.spriteapp.cn/picture/2017/1002/59d1fd9211413__b.jpg",
      "is_gif": false,
      "love": "1.7k",
      "name": "我爱你小酒窝~",
      "original_pid": "0",
      "passtime": "2017-10-09 14:15:01",
      "playcount": "112971",
      "playfcount": "11221",
      "profile_image": "http://wimg.spriteapp.cn/profile/large/2017/03/25/58d62c488484f_mini.jpg",
      "repost": "332",
      "screen_name": "我爱你小酒窝~",
      "status": "4",
      "t": 1507529701,
      "tag": "",
      "text": "假期过后上班时的你,简直一摸一样!",
      "theme_id": "0",
      "theme_name": "",
      "theme_type": "0",
      "themes": null,
      "top_cmt": null,
      "type": "41",
      "user_id": "20005106",
      "videotime": 25,
      "videouri": "http://wvideo.spriteapp.cn/video/2017/1002/59d1fd922d0ea_wpd.mp4",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "480"
    },
    {
      "bimageuri": "",
      "bookmark": "18",
      "cache_version": 2,
      "cai": "28",
      "cdn_img": "http://wimg.spriteapp.cn/ugc/2018/08/05/5b65d25dcf7d7.gif",
      "comment": "71",
      "create_time": null,
      "created_at": "2018-08-05 09:42:01",
      "ding": "358",
      "favourite": "18",
      "hate": "28",
      "height": "223",
      "image_small": null,
      "image0": "http://wimg.spriteapp.cn/ugc/2018/08/05/5b65d25dcf7d7.gif",
      "image1": "http://wimg.spriteapp.cn/ugc/2018/08/05/5b65d25dcf7d7.gif",
      "image2": "http://wimg.spriteapp.cn/ugc/2018/08/05/5b65d25dcf7d7.gif",
      "is_gif": false,
      "love": "358",
      "name": "鲁尼古拉斯",
      "original_pid": "0",
      "passtime": "2018-08-05 09:42:01",
      "playcount": null,
      "playfcount": null,
      "profile_image": "http://wimg.spriteapp.cn/profile/large/2017/06/17/59451ec71ac4a_mini.jpg",
      "repost": "12",
      "screen_name": "鲁尼古拉斯",
      "status": "4",
      "t": 1533433321,
      "tag": "",
      "text": "这么漂亮的眼睛见过没有?仿佛看到两颗璀璨的星辰",
      "theme_id": "56910",
      "theme_name": "一大波萌娃",
      "theme_type": "1",
      "themes": null,
      "top_cmt": null,
      "type": "10",
      "user_id": "20763203",
      "videotime": 0,
      "videouri": "",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "227"
    },
    {
      "bimageuri": "http://wimg.spriteapp.cn/picture/2018/0518/24e4371c-5a87-11e8-a83c-1866daeb0df1_wpd.jpg",
      "bookmark": "38",
      "cache_version": 2,
      "cai": "8",
      "cdn_img": "http://wimg.spriteapp.cn/picture/2018/0518/24e4371c-5a87-11e8-a83c-1866daeb0df1_wpd.jpg",
      "comment": "3",
      "create_time": null,
      "created_at": "2018-05-20 09:09:01",
      "ding": "105",
      "favourite": "38",
      "hate": "8",
      "height": "1280",
      "image_small": "http://wimg.spriteapp.cn/picture/2018/0518/24e4371c-5a87-11e8-a83c-1866daeb0df1_wpd.jpg",
      "image0": "http://wimg.spriteapp.cn/picture/2018/0518/24e4371c-5a87-11e8-a83c-1866daeb0df1_wpd.jpg",
      "image1": "http://wimg.spriteapp.cn/picture/2018/0518/24e4371c-5a87-11e8-a83c-1866daeb0df1_wpd.jpg",
      "image2": "http://wimg.spriteapp.cn/picture/2018/0518/24e4371c-5a87-11e8-a83c-1866daeb0df1_wpd.jpg",
      "is_gif": false,
      "love": "105",
      "name": "内涵神评湿",
      "original_pid": "0",
      "passtime": "2018-05-20 09:09:01",
      "playcount": "2476",
      "playfcount": "85",
      "profile_image": "http://wimg.spriteapp.cn/profile/large/2018/04/21/5adaa0fba68f9_mini.jpg",
      "repost": "12",
      "screen_name": "内涵神评湿",
      "status": "4",
      "t": 1526778541,
      "tag": "",
      "text": "排骨切块,洗净,冷水加葱姜料酒焯水,打去浮沫,小火20分钟,冲洗干净,控干水分,拍淀粉,七成油温炸制金黄备用。      锅烧少许油,半勺糖,半勺醋,适量盐,半勺番茄酱,熬制粘稠,少量勾芡,下入排骨翻炒均匀,撒芝麻,完成。",
      "theme_id": "123",
      "theme_name": "美食频道",
      "theme_type": "1",
      "themes": null,
      "top_cmt": null,
      "type": "41",
      "user_id": "22368727",
      "videotime": 53,
      "videouri": "http://wvideo.spriteapp.cn/video/2018/0518/24e4371c-5a87-11e8-a83c-1866daeb0df1_wpd.mp4",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "720"
    },
    {
      "bimageuri": "",
      "bookmark": "71",
      "cache_version": 2,
      "cai": "42",
      "cdn_img": "http://wimg.spriteapp.cn/ugc/2018/03/18/5aadbc4f4d4f2.gif",
      "comment": "139",
      "create_time": null,
      "created_at": "2018-03-19 15:04:01",
      "ding": "943",
      "favourite": "71",
      "hate": "42",
      "height": "267",
      "image_small": null,
      "image0": "http://wimg.spriteapp.cn/ugc/2018/03/18/5aadbc4f4d4f2.gif",
      "image1": "http://wimg.spriteapp.cn/ugc/2018/03/18/5aadbc4f4d4f2.gif",
      "image2": "http://wimg.spriteapp.cn/ugc/2018/03/18/5aadbc4f4d4f2.gif",
      "is_gif": false,
      "love": "943",
      "name": "搞笑内涵侠",
      "original_pid": "0",
      "passtime": "2018-03-19 15:04:01",
      "playcount": null,
      "playfcount": null,
      "profile_image": "http://wimg.spriteapp.cn/profile/large/2017/03/01/58b6ed2126d85_mini.jpg",
      "repost": "124",
      "screen_name": "搞笑内涵侠",
      "status": "4",
      "t": 1521443041,
      "tag": "",
      "text": "割完蛋蛋,一脸生无可恋的表情,好可怜啊",
      "theme_id": "0",
      "theme_name": "",
      "theme_type": "0",
      "themes": null,
      "top_cmt": null,
      "type": "10",
      "user_id": "19064947",
      "videotime": 0,
      "videouri": "",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "182"
    },
    {
      "bimageuri": "http://wimg.spriteapp.cn/picture/2018/0817/5b763f570db28__b.jpg",
      "bookmark": "89",
      "cache_version": 2,
      "cai": "27",
      "cdn_img": "http://wimg.spriteapp.cn/picture/2018/0817/5b763f570db28__b.jpg",
      "comment": "124",
      "create_time": null,
      "created_at": "2018-08-18 20:05:02",
      "ding": "710",
      "favourite": "89",
      "hate": "27",
      "height": "480",
      "image_small": "http://wimg.spriteapp.cn/picture/2018/0817/5b763f570db28__b.jpg",
      "image0": "http://wimg.spriteapp.cn/picture/2018/0817/5b763f570db28__b.jpg",
      "image1": "http://wimg.spriteapp.cn/picture/2018/0817/5b763f570db28__b.jpg",
      "image2": "http://wimg.spriteapp.cn/picture/2018/0817/5b763f570db28__b.jpg",
      "is_gif": false,
      "love": "710",
      "name": "全球领先在线视频",
      "original_pid": "0",
      "passtime": "2018-08-18 20:05:02",
      "playcount": "23964",
      "playfcount": "7175",
      "profile_image": "http://wimg.spriteapp.cn/profile/large/2018/08/06/5b6742613dbe7_mini.jpg",
      "repost": "75",
      "screen_name": "全球领先在线视频",
      "status": "4",
      "t": 1534593902,
      "tag": "",
      "text": "拳皇98中韩对决,赏心悦目的操作",
      "theme_id": "55163",
      "theme_name": "主版块",
      "theme_type": "1",
      "themes": null,
      "top_cmt": null,
      "type": "41",
      "user_id": "19634336",
      "videotime": 242,
      "videouri": "http://wvideo.spriteapp.cn/video/2018/0817/5b763f576bb4c_wpd.mp4",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "848"
    },
    {
      "bimageuri": "",
      "bookmark": "542",
      "cache_version": 2,
      "cai": "54",
      "cdn_img": null,
      "comment": "160",
      "create_time": null,
      "created_at": "2018-08-18 03:16:01",
      "ding": "1370",
      "favourite": "542",
      "hate": "54",
      "height": "0",
      "image_small": null,
      "image0": null,
      "image1": null,
      "image2": null,
      "is_gif": null,
      "love": "1.3k",
      "name": "神马情况这是",
      "original_pid": "0",
      "passtime": "2018-08-18 03:16:01",
      "playcount": null,
      "playfcount": null,
      "profile_image": "http://wimg.spriteapp.cn/profile/large/2018/03/21/5ab21157ebeaa_mini.jpg",
      "repost": "86",
      "screen_name": "神马情况这是",
      "status": "4",
      "t": 1534533361,
      "tag": "",
      "text": "“我爱你”的经典表达方式 :周星驰:我养你啊!苏轼:不思量,自难忘。黄伟文:余生请你指教。王家卫:那一刻,我很暖。夏目漱石:今晚月色真美。张学友:很想带你去吹吹风。玛格丽特:我在床上,饭在锅里。范仲淹:酒入愁肠,化作相思泪。李白:郎骑竹马来,绕床弄青梅。张爱玲:你还不来,我怎敢老去。钱武肃王:陌上花开,可缓缓归矣。方文山:天青色等烟雨,而我在等你。刀郎:自你离开以后,从此就丢了温柔。元稹:曾经沧海难为水,除去巫山不是云。张国荣:就让我陪你唱一辈子戏,不行吗?王小波:你好哇,李银河,见到你真高兴。李之仪:只愿君心似我心,定不负相思意。柳永:衣带渐宽终不悔,为伊消得人憔悴。林夕:你是我这一生等了半世未拆的礼物。李商隐:直道相思了无益,未妨惆怅是清狂。仓央嘉措:世间安得双全法,不负如来不负卿。冯唐:春水初生,春林初盛,春风十里,不如你。纳兰性德:凄凉别后两应同,最是不胜清怨月明中。鲁迅:我爱子君,仗着她逃出这寂静和空虚。卓别林:我可以选择让你看见,也可以选择坚持不让你看见。李宗盛:春风再美也比不上你的笑,没见过你的人不会明了。顾城:草在结它的种子,风在摇它的叶子,我们站着,不说话,就十分美好。沈从文:我行过许多地方的桥,看过许多次数的云,喝过许多种类的酒, 却只爱过一个正当最好年龄的人。所以,你的“我爱你”怎么表达呢?",
      "theme_id": "63674",
      "theme_name": "原创段子手",
      "theme_type": "1",
      "themes": null,
      "top_cmt": null,
      "type": "29",
      "user_id": "17588230",
      "videotime": 0,
      "videouri": "",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "0"
    },
    {
      "bimageuri": "http://wimg.spriteapp.cn/picture/2018/0406/5ac749108a488_wpd.jpg",
      "bookmark": "17",
      "cache_version": 2,
      "cai": "53",
      "cdn_img": "http://wimg.spriteapp.cn/picture/2018/0406/5ac749108a488_wpd.jpg",
      "comment": "19",
      "create_time": null,
      "created_at": "2018-04-13 06:51:01",
      "ding": "238",
      "favourite": "17",
      "hate": "53",
      "height": "640",
      "image_small": "http://wimg.spriteapp.cn/picture/2018/0406/5ac749108a488_wpd.jpg",
      "image0": "http://wimg.spriteapp.cn/picture/2018/0406/5ac749108a488_wpd.jpg",
      "image1": "http://wimg.spriteapp.cn/picture/2018/0406/5ac749108a488_wpd.jpg",
      "image2": "http://wimg.spriteapp.cn/picture/2018/0406/5ac749108a488_wpd.jpg",
      "is_gif": false,
      "love": "238",
      "name": "胡成功导演",
      "original_pid": "0",
      "passtime": "2018-04-13 06:51:01",
      "playcount": "22274",
      "playfcount": "1435",
      "profile_image": "http://wx.qlogo.cn/mmopen/vi_32/PiajxSqBRaEKE3bXR0UdVibEMERmAcmXfr7UicpJPp09Xd8kpibU18lPoF8rK8wC36DL6zggo8Vhqib4QBZibBbepySA/0",
      "repost": "11",
      "screen_name": "胡成功导演",
      "status": "4",
      "t": 1523573461,
      "tag": "",
      "text": "有梦想,有责任!",
      "theme_id": "55163",
      "theme_name": "主版块",
      "theme_type": "1",
      "themes": null,
      "top_cmt": null,
      "type": "41",
      "user_id": "21504912",
      "videotime": 50,
      "videouri": "http://wvideo.spriteapp.cn/video/2018/0406/5ac749108a488_wpd.mp4",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "356"
    },
    {
      "bimageuri": "",
      "bookmark": "8",
      "cache_version": 2,
      "cai": "6",
      "cdn_img": "http://wimg.spriteapp.cn/ugc/2018/04/16/5ad47be72e33b.gif",
      "comment": "10",
      "create_time": null,
      "created_at": "2018-04-19 07:36:01",
      "ding": "145",
      "favourite": "8",
      "hate": "6",
      "height": "211",
      "image_small": null,
      "image0": "http://wimg.spriteapp.cn/ugc/2018/04/16/5ad47be72e33b.gif",
      "image1": "http://wimg.spriteapp.cn/ugc/2018/04/16/5ad47be72e33b.gif",
      "image2": "http://wimg.spriteapp.cn/ugc/2018/04/16/5ad47be72e33b.gif",
      "is_gif": false,
      "love": "145",
      "name": "趣图V",
      "original_pid": "0",
      "passtime": "2018-04-19 07:36:01",
      "playcount": null,
      "playfcount": null,
      "profile_image": "http://wimg.spriteapp.cn/profile/large/2017/03/02/58b6feb82e30f_mini.jpg",
      "repost": "6",
      "screen_name": "趣图V",
      "status": "4",
      "t": 1524094561,
      "tag": "",
      "text": "完全诠释了,还没开始就已经结束了",
      "theme_id": "17083",
      "theme_name": "爆笑Gif",
      "theme_type": "1",
      "themes": null,
      "top_cmt": null,
      "type": "10",
      "user_id": "20327111",
      "videotime": 0,
      "videouri": "",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "299"
    },
    {
      "bimageuri": "http://wimg.spriteapp.cn/picture/2018/0702/5b39fcb2216b4__b.jpg",
      "bookmark": "18",
      "cache_version": 2,
      "cai": "23",
      "cdn_img": "http://wimg.spriteapp.cn/picture/2018/0702/5b39fcb2216b4__b.jpg",
      "comment": "224",
      "create_time": null,
      "created_at": "2018-07-03 14:36:02",
      "ding": "817",
      "favourite": "18",
      "hate": "23",
      "height": "1024",
      "image_small": "http://wimg.spriteapp.cn/picture/2018/0702/5b39fcb2216b4__b.jpg",
      "image0": "http://wimg.spriteapp.cn/picture/2018/0702/5b39fcb2216b4__b.jpg",
      "image1": "http://wimg.spriteapp.cn/picture/2018/0702/5b39fcb2216b4__b.jpg",
      "image2": "http://wimg.spriteapp.cn/picture/2018/0702/5b39fcb2216b4__b.jpg",
      "is_gif": false,
      "love": "817",
      "name": "白头人间_",
      "original_pid": "0",
      "passtime": "2018-07-03 14:36:02",
      "playcount": "43504",
      "playfcount": "9083",
      "profile_image": "http://wimg.spriteapp.cn/profile/large/2018/04/28/5ae412c90ee7b_mini.jpg",
      "repost": "22",
      "screen_name": "白头人间_",
      "status": "4",
      "t": 1530599762,
      "tag": "",
      "text": "老物件了,小时候的回忆啊。【我们都怀旧/活动精选】",
      "theme_id": "55163",
      "theme_name": "主版块",
      "theme_type": "1",
      "themes": null,
      "top_cmt": null,
      "type": "41",
      "user_id": "17071501",
      "videotime": 20,
      "videouri": "http://wvideo.spriteapp.cn/video/2018/0702/5b39fcb2379ab_wpd.mp4",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "576"
    },
    {
      "bimageuri": "http://wimg.spriteapp.cn/picture/2018/0506/6d701778-50d0-11e8-8743-1866daeb0df1_wpd.jpg",
      "bookmark": "52",
      "cache_version": 2,
      "cai": "12",
      "cdn_img": "http://wimg.spriteapp.cn/picture/2018/0506/6d701778-50d0-11e8-8743-1866daeb0df1_wpd.jpg",
      "comment": "20",
      "create_time": null,
      "created_at": "2018-05-06 16:00:07",
      "ding": "428",
      "favourite": "52",
      "hate": "12",
      "height": "640",
      "image_small": "http://wimg.spriteapp.cn/picture/2018/0506/6d701778-50d0-11e8-8743-1866daeb0df1_wpd.jpg",
      "image0": "http://wimg.spriteapp.cn/picture/2018/0506/6d701778-50d0-11e8-8743-1866daeb0df1_wpd.jpg",
      "image1": "http://wimg.spriteapp.cn/picture/2018/0506/6d701778-50d0-11e8-8743-1866daeb0df1_wpd.jpg",
      "image2": "http://wimg.spriteapp.cn/picture/2018/0506/6d701778-50d0-11e8-8743-1866daeb0df1_wpd.jpg",
      "is_gif": false,
      "love": "428",
      "name": "我爱你小酒窝~",
      "original_pid": "0",
      "passtime": "2018-05-06 16:00:07",
      "playcount": "9478",
      "playfcount": "951",
      "profile_image": "http://wimg.spriteapp.cn/profile/large/2018/02/24/5a91895a832cd_mini.jpg",
      "repost": "101",
      "screen_name": "我爱你小酒窝~",
      "status": "4",
      "t": 1525593607,
      "tag": "",
      "text": "金毛:让你天天狗肉汤,狗肉汤,我不要面子的啊",
      "theme_id": "56939",
      "theme_name": "动物成了精",
      "theme_type": "1",
      "themes": null,
      "top_cmt": null,
      "type": "41",
      "user_id": "20005106",
      "videotime": 167,
      "videouri": "http://wvideo.spriteapp.cn/video/2018/0506/6d701778-50d0-11e8-8743-1866daeb0df1_wpd.mp4",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "360"
    },
    {
      "bimageuri": "http://wimg.spriteapp.cn/picture/2018/0310/9fb8d90c244a11e89d87842b2b4c75ab_wpd.jpg",
      "bookmark": "86",
      "cache_version": 2,
      "cai": "207",
      "cdn_img": "http://wimg.spriteapp.cn/picture/2018/0310/9fb8d90c244a11e89d87842b2b4c75ab_wpd.jpg",
      "comment": "383",
      "create_time": null,
      "created_at": "2018-03-13 07:45:02",
      "ding": "1197",
      "favourite": "86",
      "hate": "207",
      "height": "854",
      "image_small": "http://wimg.spriteapp.cn/picture/2018/0310/9fb8d90c244a11e89d87842b2b4c75ab_wpd.jpg",
      "image0": "http://wimg.spriteapp.cn/picture/2018/0310/9fb8d90c244a11e89d87842b2b4c75ab_wpd.jpg",
      "image1": "http://wimg.spriteapp.cn/picture/2018/0310/9fb8d90c244a11e89d87842b2b4c75ab_wpd.jpg",
      "image2": "http://wimg.spriteapp.cn/picture/2018/0310/9fb8d90c244a11e89d87842b2b4c75ab_wpd.jpg",
      "is_gif": false,
      "love": "1.1k",
      "name": "终结者绎",
      "original_pid": "0",
      "passtime": "2018-03-13 07:45:02",
      "playcount": "83204",
      "playfcount": "14741",
      "profile_image": "http://wimg.spriteapp.cn/profile/20170508150613.jpg",
      "repost": "204",
      "screen_name": "终结者绎",
      "status": "4",
      "t": 1520898302,
      "tag": "",
      "text": "兄弟,你是不是对帅有什么误解?",
      "theme_id": "0",
      "theme_name": "",
      "theme_type": "0",
      "themes": null,
      "top_cmt": null,
      "type": "41",
      "user_id": "20730232",
      "videotime": 29,
      "videouri": "http://wvideo.spriteapp.cn/video/2018/0310/9fb8d90c244a11e89d87842b2b4c75ab_wpd.mp4",
      "voicelength": null,
      "voicetime": null,
      "voiceuri": null,
      "weixin_url": null,
      "width": "480"
    }
  ],
  "msg": "成功!"
}
  1. 写猜数字游戏,如果输入有误,提示重新输入,直达输入正确为止。比如:输入数字的时候没有按要求输入,提示重新输入
import random
num = random.randint(1,100)
while True:

    
    try:
        n = int(input("请输入数字:"))
        if n > num:
            print ("大了,再小点!")
        if n < num:
            print ("小了,再大点!")
        elif n==num:
            print ("congradulation!!你猜对了")
            break
    except:
        print ("输入错误,请重新输入")
输出结果:
请输入数字:23a
输入错误,请重新输入
请输入数字:23
小了,再大点!
请输入数字:45
小了,再大点!
请输入数字:68
小了,再大点!
请输入数字:90
大了,再小点!
请输入数字:70
小了,再大点!
请输入数字:78
大了,再小点!
请输入数字:75
小了,再大点!
请输入数字:76
congradulation!!你猜对了
  1. 写学生管理系统的添加学生功能(数据需要本地化),
    要求除了保存学生的基本信息以外还要保存学生的学号,但是学号需要自动生成,生成原则:
    添加第一个学生对应的学号是:py001
    第二次添加的学生的学号是:py002
    ...
    如果前面的学生因为各种原因被移除了,那后面添加学生的时候原则不变,
    就是比如上次已经添加到py012,那么前面不管有没有删除情况,再次添加学生的学号是py013
n=0
while True:
    with open('./files/add_student.json', 'r', encoding='utf-8') as f:
        content = json.load(f)


    name = input("请输入姓名:")
    sex = input("请输入性别:")
    phone_num = input("请输入电话号码:")
    num = 'py00' + str(n)
    n += 1
    student = {"num": num, "name": name, "sex": sex, "phone_num": phone_num}
    content.append(student)
    with open('./files/add_student.json', 'w', encoding='utf-8') as f:
        json.dump(content, f,ensure_ascii=False,indent=2)
输入:
请输入姓名:hyc
请输入性别:男
请输入电话号码:132
请输入姓名:王渠江
请输入性别:男
请输入电话号码:2345
输出:
[  
{
    "num": "py000",
    "name": "hyc",
    "sex": "男",
    "phone_num": "132"
  },
  {
    "num": "py001",
    "name": "王渠江",
    "sex": "男",
    "phone_num": "2345"
  }
]
上一篇 下一篇

猜你喜欢

热点阅读