会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132661个问题
JAVA 全系列/第二十阶段:租房网(Spring Cloud最新架构)/Livegoods房屋海选平台 1666楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/手写服务器项目(旧) 1667楼
JAVA 全系列/第三阶段:数据库编程/SQL 语言 1668楼

from tkinter import *
from tkinter import messagebox
import random


class Application(Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.master = master
        self.pack()
        self.createWidget()

    def createWidget(self):
        btnText = (("MC", "M+", "M-", "MR"),
                   ("C", "±", "÷", "x"),
                   (7, 8, 9, "-"),
                   (4, 5, 6, "+"),
                   (1, 2, 3, "="),
                   (0, "."))

        Entry(self).grid(row=0,column=0,columnspan=4,pady=10)


        for rindex, r in enumerate(btnText):
            for cindex, c in enumerate(r):
                if c == "=":
                    Button(self, text=c, width=2)\
                    .grid(row = rindex+1, column=cindex, rowspan=2, sticky=NSEW)
                elif c == 0:
                    Button(self, text=c, width=2)\
                    .grid(row=rindex+1, column=cindex, columnspan=2, sticky=NSEW )
                elif c == ".":
                    Button(self, text=c,width=2)\
                    .grid(row=rindex+1, column=cindex+1, sticky=NSEW)
                else:
                    Button(self, text=c,width=2)\
                    .grid(row=rindex,column=cindex,sticky=NSEW)




if __name__ == '__main__':
    root = Tk()
    root.geometry("500x500+200+200")
    app = Application(master=root)
    root.mainloop()


JMR`IWPAPX3)$@0Y5AUZG0D.png


老师,我第一次可以打包成功,但后来就不行了,

这个是什么意思呢?

Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 1670楼
Python 全系列/第五阶段:数据库编程/python操作mysql(旧) 1672楼

<template>
  <div id="app">
    <hello>
      <template v-slot:header>
        <div>{{msg}}</div>
      </template>
      <template v-slot:body>
        <div>我是内容部分</div>
      </template>
      <template v-slot:footer>
        <div>我是底部</div>
      </template>
      <template v-slot:default="slotProps">
        <h3>{{slotProps.demo}}</h3>
      </template>
    </hello>
    <DyMy />
  </div>
</template>

<script>
import hello from "./components/hello.vue"
import DyMy from "./components/DyMy.vue"
export default {
  name: 'App',
  data(){
    return{
      msg:"我是头部"
    }
  },
  methods:{
  },
  components: {
    hello,
    DyMy,
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
<template>
  <div>
      <h3>我是动态组件</h3>
      <button @click="changeViewHandle">切换视图显示</button>
      <component :is="currentComponent"></component>
  </div>
</template>

<script>
import child1 from "./child1"
import child2 from "./child2"
export default {
    data(){
        return{
            currentComponent:child1
        }
    },
    methods:{
        changeViewHandle(){
            if(this.currentComponent===child1){
                this.currentComponent=child2
            }else{
                this.currentComponent=child1
            }
        }
    },
    components: {
        child1,
        child2,
    },
}
</script>

<style>

</style>

第一段代码是App.vue,第二个是DyMy.vue,视频15分钟的时候,讲动态组件的时候按照视频上写的代码,控制台有警告,为啥与视频一样会有警告呢?

image.png

Python 全系列/第八阶段:Vue框架/vue框架 1673楼

老师,你看一下我这个代码,,在TreeMap中添加进去了三个元素  ,只能打印出一个

package com.itchenzn03.collection.map;

import java.util.Map;
import java.util.TreeMap;

/**
 * 测试TreeMap的使用
 * 1.底层使用的是红黑树
 * 2.底层将我们存进去的数据按key自动进行升序排序
 */

public class TestTreeMap01 {
    public static void main(String[] args){
        Map<Integer,String> treemap=new TreeMap<>();
        treemap.put(10,"aa");
        treemap.put(2,"bb");
        treemap.put(8,"cc");

        for (Integer key:treemap.keySet()){
            System.out.println(key+"-----"+treemap.get(key));
        }

        System.out.println("对一些较为负责的对象自定义的排序规则");
        System.out.println("-------------------------------------");

        Map<Emp,String> tp=new TreeMap<>();
       tp.put(new Emp(1001,"张三",500),"aa");
       tp.put(new Emp(1002,"李四",600),"bb");
       tp.put(new Emp(1003,"赵六",600),"cc");


        System.out.println(tp.size());

        for (Emp emp:tp.keySet()){
            System.out.println(emp+"--------"+tp.get(emp));
        }

        //System.out.println(treemap1.keySet());

    }
}

//实现Comparable接口  重写里面的ComparableTo<E>方法  定义排序规则  对一些较为负责的对象进行排序
class Emp implements Comparable{
    int id;
    String name;
    double salary;



    public Emp(int id, String name, double salary) {
        this.id = id;
        this.name = name;
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "id:"+id+",name:"+name+",salary:"+salary;
    }

    @Override
    public int compareTo(Object o) {   //负数:-1   正数:1   相等:0
        if (this.salary>salary){
            return 1;
        }else if (this.salary<salary){
            return -1;
        }else{
            if (this.id>id){
                return 1;
            }else if (this.id<id){
                return -1;
            }else{
                return 0;
            }
        }

    }

}

效果:

image.png

JAVA 全系列/第二阶段:JAVA 基础深化和提高/容器(旧) 1675楼
Python 全系列/第二十三阶段:人工智能基础_机器学习理论和实战(旧)/GBDT算法 1677楼
Python 全系列/第四阶段:函数式编程和核心特性/正则表达式 1678楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/容器(旧) 1679楼
Python 全系列/第五阶段:数据库编程/MySQL数据库的使用 1680楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637