标签:ges count main test mon range ref start sed
Python 和 Django
按照博主Hongten的记录学习一遍,Hongten博主地址
python安装教程:python安装教程
Django安装教程:Django安装教程
列表运行示例:
1
1 >>> def create_empty_list(): 2 return [] 3 4 >>> def create_common_list(): 5 return [‘a‘,‘b‘,‘c‘,1,3,5] 6 7 >>> def create_common_list2(): 8 return [x for x in range(1,10)] 9 10 >>> def str_to_list(s): 11 if s != None: 12 return list(s) 13 else: 14 return [] 15 16 17 >>> def main(): 18 test_listA = create_empty_list() 19 print(test_listA) 20 print(‘#‘*50) 21 test_listB = create_common_list() 22 print(test_listB) 23 print(‘#‘*50) 24 test_listC = create_common_list2() 25 print(test_listC) 26 print(‘#‘*50) 27 test_str = ‘ i want to talk‘ 28 test_listD = str_to_list(test_str) 29 print(test_listD) 30 31 32 >>> if __name__ == ‘__main__‘: 33 main ()
2
>>> counter = 100 >>> miles = 1000.0 >>> name = "minglang" >>> numberA,numberB,nameC = 1,2,"Minglang" >>> list = [counter,miles,name,numberA,numberB,nameC] >>> print (list) [100, 1000.0, ‘minglang‘, 1, 2, ‘Minglang‘] >>> #注释用"#" >>> for element in list: print(element) 100 1000.0 minglang 1 2 Minglang >>> print (list[0]) #获取列表list里的第一个元素值 100 >>> print (list[-1]) #获取列表list最后一个元素 Minglang >>> print (len(list)) #list列表的长度 6 >>> num_inc_list = range(10) >>> print (num_inc_list) range(0, 10) >>> for inc_list in num_inc_list: print(inc_list) 0 1 2 3 4 5 6 7 8 9 >>>
标签:ges count main test mon range ref start sed
原文地址:http://www.cnblogs.com/yml6/p/6109101.html