摘要: 1. 阅读全文
posted @ 2018-01-09 14:42 王思磊 阅读(253) 评论(0) 推荐(0) 编辑
摘要: # 递归 自己调用自己def test1(): num = int(input('please enter a number:')) if num % 2 == 0: # 判断输入的数字是不是偶数 return True # 如果是偶数的话,程序就退出了,返回true print('不是偶数请重新输 阅读全文
posted @ 2018-01-09 14:40 王思磊 阅读(134) 评论(0) 推荐(0) 编辑
摘要: import sys# 一个python文件就是一个模块# 标准模块 python自带的,不需要安装的# 第三方模块 需要安装,别人提供的 pip install xxx自动安装# 下载安装包,解压,在命令行里面进入到这个解压之后的目录,执行python xxx.py install# 自己写的 自 阅读全文
posted @ 2018-01-09 14:39 王思磊 阅读(114) 评论(0) 推荐(0) 编辑
摘要: # int string list tuple dict bool float set# 集合,天生去重# 定义集合s = set() # 空的集合s1 = {'1', '2', '3', '3'}print(s1)lists = [1, 2, 3, 4, 5, 5, 6, 7, 8]print(s 阅读全文
posted @ 2018-01-09 14:38 王思磊 阅读(119) 评论(0) 推荐(0) 编辑
摘要: # 函数/方法/功能# 说白了,函数就是把一堆代码组合到一起变成一个整体# 函数不调用不会被执行# 提高代码的复用性# 全局变量/局部变量# 位置参数/必填参数# def hello(file_name, content=''): # 这里的参数叫做形参,形式参数# # 函数里面变量是局部变量# f 阅读全文
posted @ 2018-01-09 14:37 王思磊 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 第一种 阅读全文
posted @ 2018-01-09 14:30 王思磊 阅读(109) 评论(0) 推荐(0) 编辑
摘要: # f = open('a.txt', 'w', encoding='utf-8')# names = ['a', 'b', 'c'] # for name in names:# f.write(name) # f.writelines(names)# f.close() s = '既然青春留不住' 阅读全文
posted @ 2018-01-09 14:20 王思磊 阅读(127) 评论(0) 推荐(0) 编辑