会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132448个问题
Python 全系列/第一阶段:Python入门/面向对象 31831楼
Python 全系列/第二阶段:Python 深入与提高/模块 31832楼

image.png

import random
import string

from django.db import models

# Create your models here.


class Student(models.Model):

    name = models.CharField(max_length=64)
    age = models.IntegerField(default=18)
    sex = models.IntegerField(choices=((1, '男'), (2, '女')), default=1)
    card = models.CharField(max_length=128)

    @classmethod
    def insert_test_data(self,num):
        """
        批量生成测试数据
        :param num: 记录数
        :return:
        """
        def random_str(row_ite, length):
            """
            :param row_ite: 从指定的可迭代的原始数据中获取字符
            :param length:  字符串的长度
            :return:  随机的字符串
            """
            return random.choices(row_ite, k=length)
        obj_li = []
        for _ in range(num):
            obj_li.append(Student(
                name = random_str(string.ascii_lowercase, random.randint(6,10)),
                age = random.randint(18,26),
                sex = random.choice([1,2]),
                card = random_str(string.digits,18)
            ))

        Student.objects.bulk_create(obj_li)

老师,我在运行上述代码插入数据的时候出现了上图中的错误,修改了类中的max_length也没用,求教。。。

Python 全系列/第十二阶段:Python_Django3框架/Django初级 31834楼

	at org.apache.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.<init>(CuratorZookeeperClient.java:80)
	... 26 more
org.apache.dubbo.config.DubboShutdownHook 2020-06-21 11:41:55   [DUBBO] Run shutdown hook now., dubbo version: 2.7.6, current host: 192.168.66.6 
org.apache.dubbo.registry.support.AbstractRegistryFactory 2020-06-21 11:41:55   [DUBBO] Close all registries [], dubbo version: 2.7.6, current host: 192.168.66.6 
org.springframework.context.support.AbstractApplicationContext 2020-06-21 11:41:55  Closing org.springframework.context.support.ClassPathXmlApplicationContext@3cb5cdba, started on Sun Jun 21 11:41:43 CST 2020 
org.apache.dubbo.config.bootstrap.DubboBootstrap 2020-06-21 11:41:55   [DUBBO] DubboBootstrap's all ServiceDiscoveries have been destroyed., dubbo version: 2.7.6, current host: 192.168.66.6 
org.apache.dubbo.config.bootstrap.DubboBootstrap 2020-06-21 11:41:55   [DUBBO] DubboBootstrap's configs have been clear., dubbo version: 2.7.6, current host: 192.168.66.6 
org.apache.dubbo.config.bootstrap.DubboBootstrap 2020-06-21 11:41:55   [DUBBO] DubboBootstrap is about to shutdown..., dubbo version: 2.7.6, current host: 192.168.66.6 
org.apache.dubbo.config.event.listener.LoggingEventListener 2020-06-21 11:41:55   [DUBBO] Dubbo Service has been destroyed., dubbo version: 2.7.6, current host: 192.168.66.6 
com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor 2020-06-21 11:41:55  class org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor was destroying!

老师,这是provider放在linux里启动后产生的logs日志,感觉还没开始它就自己终止了,启动脚本里的Main方法我也改成org.apache的了,不知道哪里出了问题,搜百度说是版本问题,您给看看

JAVA 全系列/第十一阶段:分布式RPC调用和分布式文件存储/Dubbo 31835楼
Python 全系列/第五阶段:数据库编程/mysql的使用 31836楼
Python 全系列/第二十四阶段:人工智能基础_深度学习理论和实战(旧)/卷积神经网络实战 31837楼
JAVA 全系列/第四阶段:网页编程和设计/Javascript 语言(旧) 31838楼
JAVA 全系列/第一阶段:JAVA 快速入门/JAVA入门和背景知识 31839楼
Python 全系列/第二阶段:Python 深入与提高/文件处理 31840楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/容器(旧) 31841楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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