python
lemonamaya
这个作者很懒,什么都没留下…
展开
-
Python基础 print()莫烦视频
print语句print(1)print('we are goning todo something')print("I'm Morvan")print('I\'m m')print('apple'+'car')print('apple'+'4')print('apple'+str(4))print(1+2)print('1+2')print(int('1')+2)print(f原创 2017-06-04 19:54:20 · 211 阅读 · 0 评论 -
Python 基础 while循环
while循环condition =1while condition<10: print(condition) condition = condition+1死循环while True: print("I'm True")原创 2017-06-04 20:12:36 · 223 阅读 · 0 评论 -
Python基础 for循环
for 循环example_list =[1,2,3,4,5,6,7,8,9,10,12,1,3]for i in example_list: print(i) print('inner of for') for windows :control+[print('outer of for')inner of for 和outer of for 是存在于for原创 2017-06-04 20:27:27 · 451 阅读 · 0 评论 -
Python基础 if条件
if条件x=1y=2z=3if x>y: print('x is greater than y.')if x<y: print('x is less than y.')if x<y<z: print('x is less than y,and y is less than z.')a=2b=2if a==b: print('a is equal to y原创 2017-06-04 21:09:25 · 271 阅读 · 0 评论 -
Python 基础 def函数
def函数 def function(): print('This is a function.') a=1+2 print(a)function()原创 2017-06-04 21:16:07 · 704 阅读 · 0 评论 -
Python 基础 读写文件
open 打开文件,当文件不存在时会创建一个空文件 打开后要执行关闭命令,closetext = 'This is my first test.\nThis is next line\nThis is last line.'print(text)my_file = open('my file.txt','w')my_file.write(text)my_file.close()在打开的文件中原创 2017-06-05 19:51:48 · 370 阅读 · 0 评论 -
isinstance函数
转自这里写链接内容今天看了下廖雪峰的网站,发现有个isinstance函数可以对参数类型进行判断:对参数类型做检查,只允许整数和浮点数类型的参数。数据类型检查可以用内置函数isinstance实现:def my_abs(x): if not isinstance(x, (int, float)): raise TypeError('bad operand type')转载 2017-06-24 14:44:17 · 4798 阅读 · 0 评论