from teatcher.models import Student 导入app(teatcher)下的模型(Student) In [11]: res = Student.objects.all().query In [12]: print(res) SELECT `teatcher_student`.`id`, `teatcher_student`.`name`, `teatcher_student`.`sex`, `teatcher_student`.`age`, `teatc
#!/uer/bin/env python # _*_ coding: utf-8 _*_ #格式1 a = 'abc' for i in range(len(a)): print a[i],'(%d)'% i a (0)b (1)c (2) #格式2 for A,i in enumerate('abc'): print i,A a 0b 1c 2 #格式2.1 b = raw_input('wartyouname:') for i,j in enumerate(b): print b[i],'
题目(1)for i in range(10): print(i) 结果:123456789 题目(2) for lst in range(100): if lst % 7 == 0 and str(7) in str(lst): print(int(lst) 解释: 这里的"%"表示取余的意思,range里的数一个个给lst, lst % 7 == 0, 如果就是取余7 ,我把他理解为7的倍数,后面的 str(7) in str(lst), 如果字符串lst里带有7,就打印出来, i
Assume you have an array of length n initialized with all 0's and are given k update operations. Each operation is represented as a triplet: [startIndex, endIndex, inc] which increments each element of subarray A[startIndex ... endIndex] (startIndex
Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive.Range sum S(i, j) is defined as the sum of the elements in nums between indices i and j (i ≤ j), inclusive. Note:A naive algorithm of O(n2) is trivial.
You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i]. Example: Given nums = [5, 2, 6, 1] To the right of 5 there are