美文网首页
(5条消息) python抓数据处理、python django

(5条消息) python抓数据处理、python django

作者: 学习微站 | 来源:发表于2022-11-25 11:34 被阅读0次

    python django127.0.0.1:8000可以运行,127.0.0.1:8000/admin不可以运行

    关于在windows下使用pycharm开发Django进入admin页面时弹出python已停止运行

    可能是Django版本问题 卸载安装

    使用pip命令来 卸载 Django

     pip uninstall django
    
    • 1

    python抓数据处理

    import wordcloud
    file = open(r"D:\PyCharm实例\抓数据\最多收藏.txt",encoding="utf-8")
    text = file.read()
    wc = wordcloud.WordCloud()
    wc.generate(text)
    image = wc.to_image()
    #stopwords = {" "}
    #wc = wordcloud.WordCloud(font_path=r"D:\PyCharm实例\抓数据\STSONG.TTF",stopwords=stopwords)
    wc = wordcloud.WordCloud(font_path=r"D:\PyCharm实例\抓数据\STSONG.TTF")
    wc.generate(text)
    image = wc.to_image()
    image.show()
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    https://blog.csdn.net/weixin_43206161

    network三个测试类

    @Slf4j
    public class test {
        public static void main(String[] args) {
            String paramScores = "[{\"dictType\":\"multiple\",\"key\":\"[\\\"1\\\"]\"," +
                    "\"score\":\"9\",\"value\":\"\",\"valueType\":0}]";
            //[{"dictType":"multiple","key":"[\"1\"]","score":"9","value":"","valueType":0}]
            List<ParamScore> paramScoreList = JSONArray.parseArray(paramScores, ParamScore.class);
            for (ParamScore paramScore : paramScoreList) {
                List<String> strings = JSONArray.parseArray(paramScore.getKey(), String.class);
                System.out.println("====" + strings);
            }
            System.out.println(paramScoreList);
    //        String paramScores = "[\n" +
    //                "    {\n" +
    //                "        \"key\": 1,\n" +
    //                "        \"valueType\": 1,\n" +
    //                "        \"value\": \"100\",\n" +
    //                "        \"score\": 6\n" +
    //                "    },\n" +
    //                "    {\n" +
    //                "        \"key\": 2,\n" +
    //                "        \"valueType\": 3,\n" +
    //                "        \"value\": \"10-20\",\n" +
    //                "        \"score\": 1\n" +
    //                "    }\n" +
    //                "]";
    //        List<ParamScore> paramScore = JSONArray.parseArray(paramScores, ParamScore.class);
    //        System.out.println(paramScore);
    //        List<String> collect = paramScore.stream().map(ParamScore::getScore).collect(Collectors.toList());
    //        collect.stream().max(Integer::max, Comparator.nullsFirst(String::compareTo)).get()
    //        List<User> collect3 = userList.stream().sorted(Comparator.comparing(User::getAddress,
    //                Comparator.nullsFirst(String::compareTo)).reversed()).collect(Collectors.toList());
    
    
    //        List<ParamScore> collect = paramScore.stream().sorted(Comparator.comparing(ParamScore::getScore,
    //                Comparator.nullsLast(String::compareTo)).reversed()).collect(Collectors.toList());
    //        System.out.println(collect);
    //        System.out.println(collect.get(0).getScore());
    
    
    //
    //        String t1= "20131011" ;
    //        String t2= "20131030" ;
    //        String t3= "20131030" ;
    //        int  result = t1.compareTo(t2);
    //        System.out.println("==" + t2.compareTo(t3));
    //        System.out.println(result);
    
    
    
    
        }
    }
    
    
    

    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    public class test2 {
        public static void main(String[] args) {
    //        List<String> realValueList = new LinkedList<>();
    //        realValueList.add("发到了计算机");
    //        realValueList.add("杜绝浪费接口");
    //        realValueList.add("发到了健康");
    //        String str = getShowStringByList(realValueList);
    //        System.out.println(str);
    
            /**
             * ["1","2","3"] 这种格式提取出来key
             */
    //        String attrValue = [\"1\",\"2\",\"3\"]';
    //        String dataValue = "[{\"key\":1,\"value\":\"街铺\"},{\"key\":2,\"value\":\"购物中心铺\"},{\"key\":3,\"value\":\"社区底商\"},{\"key\":4,\"value\":\"写字楼园区底商\"},{\"key\":5,\"value\":\"地铁铺\"},{\"key\":6,\"value\":\"高铁机场口岸商业铺\"},{\"key\":7,\"value\":\"市场档口铺\"},{\"key\":8,\"value\":\"校园铺\"}]";
    //        System.out.println(JSONObject.parseArray(attrValue, String.class));
    //        //字典值
    //        System.out.println(JSONObject.parseArray(dataValue, KeyValueResp.class));
    
    
    //        List<String> realKeyList = getRealKeyList(real);
    //        System.out.println(realKeyList);
    //        for (String realKey : realKeyList) {
    //            System.out.println(realKey);
    //        }
    
        }
    
        private static String getShowStringByList(List<String> realValueList) {
            if (CollectionUtil.isNotEmpty(realValueList)) {
                return "";
            }
            String s = "";
            for (String item : realValueList) {
                s += item + ",";
            }
            return StringUtils.isBlank(s) ? null : s.substring(0, s.length() - 1);
        }
    
        /**
         * ["1","2","3"] 这种格式提取出来key
         */
        public static List<String> getRealKeyList(String real) {
            List<String> realKeyList = JSONObject.parseArray(real, String.class);
            return realKeyList;
        }
    }
    
    
    

    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    public class test3 {
        public static void main(String[] args) {
            List<ParamScore> paramScores = new LinkedList<>();
            ParamScore paramScore = new ParamScore();
            paramScore.setScore("21");
            paramScores.add(paramScore);
            ParamScore paramScore1 = new ParamScore();
            paramScore1.setScore("25");
            paramScores.add(paramScore1);
            ParamScore paramScore2 = new ParamScore();
            paramScore2.setScore("14");
            paramScores.add(paramScore2);
            ParamScore paramScore3 = new ParamScore();
            paramScore3.setScore("13");
            paramScores.add(paramScore3);
            List<ParamScore> collect = paramScores.stream().sorted(Comparator.comparing(ParamScore::getScore,
                    Comparator.nullsLast(String::compareTo)).reversed()).collect(Collectors.toList());
            System.out.println(collect);
            String max = null != collect.get(0) && null != collect.get(0).getScore() ? collect.get(0).getScore() : null;
            System.out.println(null != max ? Double.valueOf(max) : Double.valueOf(0));
        }
    }
    
    
    

    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23

    本文使用 文章同步助手 同步

    相关文章

      网友评论

          本文标题:(5条消息) python抓数据处理、python django

          本文链接:https://www.haomeiwen.com/subject/pawqtdtx.html