会员
周边
捐助
新闻
博问
闪存
赞助商
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
lynn_chen
Powered by
博客园
博客园
|
首页
|
新随笔
|
联系
|
订阅
|
管理
2018年5月3日
模块 - 概念+安装
摘要: 模块: 模块就是一个python 文件 1、标准模块、标准包 #pyth 自带的这些模块,直接import 就能用的 (如 string,random,datetime,os,json) 2、第三方模块,别人写好的一些模块,要安装后才可以用 安装方法: #1、傻瓜式安装 pip install py
阅读全文
posted @ 2018-05-03 15:25 lynn_chen
阅读(190)
评论(0)
推荐(0)
编辑
内置函数
摘要: 内置函数 python 自带的一些函数,直接拿过来能用的 id() #看内存地址type() #看数据类型print() #打印input() #输入list() #转listset() #转集合str() #转字符串dict() #转字典int() #转 intfloat() #转 float 类
阅读全文
posted @ 2018-05-03 14:56 lynn_chen
阅读(110)
评论(0)
推荐(0)
编辑
函数 - 递归
摘要: def test1(): num = int(input('please enter a number')) if num % 2 == 0: #判断输入的数字是不是偶数 reture True #如果是偶数的话,程序就退出了,返回true print('不是偶数请重新输入') return tes
阅读全文
posted @ 2018-05-03 14:50 lynn_chen
阅读(98)
评论(0)
推荐(0)
编辑
函数 - 不固定参数
摘要: def syz(*args): #参数值 print(args) syz()syz('niuhanyang',123,'3333')syz('ls','sdf',111,555,'niuniu','dashu','andashu') ###【*args:参数组】1、非必填参数2、没有参数个数限制3、
阅读全文
posted @ 2018-05-03 14:46 lynn_chen
阅读(131)
评论(0)
推荐(0)
编辑
函数 - json
摘要: import json 注:json 串里面只有双引号,没有单引号bejson.com 在线检验json 的格式是否正确 ##json 串是一个字符串 将文件中包含字典的字符串转为字典,方法:f = open('product.json',encoding = 'utf-8')res = f.rea
阅读全文
posted @ 2018-05-03 14:33 lynn_chen
阅读(158)
评论(0)
推荐(0)
编辑
函数 - 举例(判断小数)
摘要: 例:写一个判断小数的函数 需求:判断小数的函数 需求分析: 1、小数点数 .count() 2、按照小数点进行分割 1.98 -> [1,98] 3、正小数:小数点左边是整数,右边也是整数 .isdigit() 4、负小数:小数点左边是以负号开头,但是只有一个负号,右边是整数 def is_floa
阅读全文
posted @ 2018-05-03 13:08 lynn_chen
阅读(295)
评论(0)
推荐(0)
编辑