会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132904个问题

<template>
  <div class="hello">
    <div>
      <span>{{shangpin.title}}</span><br><span>{{shangpin.content}}</span>
    </div>
  </div>
</template>

<script>
import axios from 'axios'
// import qs from 'querystring'
import qs from 'querystring'
export default {
  name: 'HelloWorld',
  data(){
    return{
     shangpin:{
       title:'',
       content:''
     },
     flag:false
    }
  },
  props: {
    msg: String
  },
  mounted(){
    var that=this
    // axios.get('http://iwenwiki.com/api/blueberrypai/getChengpinDetails.php').then(function(res){
    //   // console.log(res);
    //   if(res.status==200){
    //     // console.log(res.data.chengpinDetails[0].content);
    //     that.shangpin.title=res.data.chengpinDetails[0].title
    //       that.shangpin.content=res.data.chengpinDetails[0].content;
       
       
    //   }
    // }).catch(function(err){
    //   console.log(err);
    // })

    // axios.get('http://iwenwiki.com:3000/search?keywords',{
    //   params:{
    //     keywords:'你瞒我瞒'
    //   }
    // }).then(res=>{
    //   console.log(res);
    // }).catch(err=>{
    //   console.log(err);
    // })

    // post请求
    //querystring.stringify 将对象变为字符串
    //querystring.parse() 将字符串变为对象
    // axios.post('http://iwenwiki.com/api/blueberrypai/login.php',qs.stringify({
    //   user_id:'iwen@qq.com',
    //   password:'iwen123',
    //   verification_code:'crfvw'
    // })).then(res=>{console.log(res);}).catch(err=>{console.log(err);})
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>

老师为啥我导入那个querystring 模块 后台就起不来呢?

image.png

image.png


WEB前端全系列/第十九阶段:Vue2知识体系(旧)/网络请求 20687楼
JAVA 全系列/第一阶段:JAVA 快速入门/JAVA入门和背景知识 20692楼
Python 全系列/第五阶段:数据库编程/mysql的使用 20693楼
Python 全系列/第二十四阶段:人工智能基础_深度学习理论和实战(旧)/Keras框架 20694楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/手写服务器项目(旧) 20695楼

from tkinter import *
from tkinter import messagebox

class Application(Frame):
    def __init__(self,master=None):
        super().__init__(master)
        self.master = master
        self.pack()
        self.create()
    def create(self):
        self.label01 = Label(self,text="用户名").pack()
        v1 = StringVar()
        self.entry01 = Entry(self,textvariable=v1).pack()
        self.label02 = Label(self, text="密码").pack()
        v1.set("admin")
        v2 = StringVar()
        self.entry02 = Entry(self, textvariable=v2,show="*").pack()
        self.btn01 = Button(self, text="登录", command=self.b).pack()


    def b(self):
        username = self.entry01.get()
        password = self.entry02.get()
        if username == "haha" and password == 123456:
            messagebox.showinfo("登录成功")
        else:
            messagebox.showinfo("登录失败")
if __name__ == "__main__":
    root = Tk()
    root.title("今日的练习")
    root.geometry("400x400+200+200")
    app = Application(master=root)
    root.mainloop()



Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\zhangzhen\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
    return self.func(*args)
  File "C:/Users/zhangzhen/PycharmProjects/zhanghzen/haha.py", line 22, in b
    username = self.entry01.get()
AttributeError: 'NoneType' object has no attribute 'get'

get为什么没有?

Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 20698楼
JAVA 全系列/第五阶段:JavaWeb开发/Servlet技术详解(旧) 20699楼
Python 全系列/第十四阶段:Python 爬虫开发/爬虫基础(旧) 20700楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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