摘要: ##########定义函数######### 如果不主动调用函数,函数是不会执行的 def say_hello(): print 'hello1' print 'hello2' print 'hello3'# 函数的调用 say_hello() def sum_2_sum(): """对两个数字的 阅读全文
posted @ 2018-09-03 15:29 正义的朋友 阅读(368) 评论(0) 推荐(0) 编辑
摘要: #######str字符串#####str字符判断大小写 url1 = 'http://www.cctv.com' url2 = 'file:///mnt' print url1.startswith('http') #找出字符是否以'...'开头 print url2.startswith('fi 阅读全文
posted @ 2018-09-03 15:29 正义的朋友 阅读(394) 评论(0) 推荐(0) 编辑
摘要: #####变量######一.命名规则 1.正常命名 可以由字母,下划线和数字组成,不能以数字开头,不能和关键字重明 2.驼峰命名法 1)大驼峰:每一个单词的首字母都大写 FirstName LastName 2)小驼峰:第一个单词以小写字母开始,后续单词的首字母大写 firstName lastN 阅读全文
posted @ 2018-09-03 15:29 正义的朋友 阅读(283) 评论(0) 推荐(0) 编辑
摘要: #######假定有下面这样的列表: names = ['fentiao', 'fendai', 'fensi', 'apple'] 输出结果为:'I have fentiao, fendai, fensi and apple.' names = ['fentiao', 'fendai', 'fen 阅读全文
posted @ 2018-09-03 15:28 正义的朋友 阅读(1184) 评论(0) 推荐(0) 编辑
摘要: #######列表######1.列表的特性 server = [['http'],['ssh'],['ftp']] server1 = [['mysql'],['firewalld']] 连接 print server+server1 索引 print server[0] 切片 print ser 阅读全文
posted @ 2018-09-03 14:48 正义的朋友 阅读(177) 评论(0) 推荐(0) 编辑