批量插入数据 bulk_create # 1.往书籍表中插入数据 1000 # for i in range(1000): # 这种插入方式 效率极低 # models.Book.objects.create(title='第%s本书'%i) book_list = [] for i in range(100000): # 时间还是很短 两者差距很大 book_list.append(models.Book(title='第%s本书'%i)) models.Book.objects.bulk_c
批量插入数据 后端: def fenye(request): book_list=[] for i in range(100): book_list.append(models.Book(title='第%s本书'%i)) models.Book.objects.bulk_create(book_list) book_qurery=models.Book.objects.all() return render(request,'fenye.html',locals()) 前端: {% for b
换行的字符串 "This string\nhas two lines" 字符串中使用单引号时应该怎么写 'You\'re right, it can\'t be a quote' 把数字变成字符串并保留两位小数 var n = 123456.789 n.toFixed(0); //"123457" n.toFixed(2); //"123456.79" parseFloat(str)str以非数字开头,则返回NaN parseFloat(str)