摘要: 1.列表的使用 shoplist = ['apple','mango' ,'carrot','banana']print ('I have ',len(shoplist),'items to purchase') print ('These items are:',)for item in shop 阅读全文
posted @ 2017-11-18 15:59 Carzy_Learner 阅读(503) 评论(0) 推荐(0) 编辑
摘要: 1.新建自己的模块 def sayhi(): print ('Hi, this is mymodule speaking.') Version = '0.1' 调用自己的模块 import mymodule mymodule.sayhi()print ('Version ', mymodule.Ve 阅读全文
posted @ 2017-11-18 15:46 Carzy_Learner 阅读(81) 评论(0) 推荐(0) 编辑
摘要: 1.全局变量写法 def func(): global x print ('x is',x) x=2 print ('Changed local x to', x)x= 50func()print ('x is still' ,x ) 2.改变形参和不改变形参设默认值用法 def say(messa 阅读全文
posted @ 2017-11-18 15:18 Carzy_Learner 阅读(83) 评论(0) 推荐(0) 编辑
摘要: 1.函数调用定义。 def sayHello(): print ('Hello World!')sayHello() 2.函数形参 def printMax(a,b): if (a>b): print ( a, 'is maximum') if (a<b): print ( b, 'is maxim 阅读全文
posted @ 2017-11-17 16:38 Carzy_Learner 阅读(76) 评论(0) 推荐(0) 编辑
摘要: 版本不同语法不同 1. print (‘’) print ‘’ 2.input 与 raw_input 3代码(if和else用法): number = 23guess = int(input ('Enter an integer:')) if guess == number: print ('Co 阅读全文
posted @ 2017-11-17 15:53 Carzy_Learner 阅读(200) 评论(0) 推荐(0) 编辑