python基础一 day15 内置函数
'\r' 回车,回到当前行的行首,而不会换到下一行,如果接着输出的话,本行以前的内容会被逐一覆盖;
'\n' 换行,换到当前位置的下一行,而不会回到行首;
# print()
# input()
# len()
# type()
# open()
# tuple()
# list()
# int()
# bool()
# set()
# dir()
# id()
# str() # print(locals()) #返回本地作用域中的所有名字
# print(globals()) #返回全局作用域中的所有名字
# global 变量
# nonlocal 变量 #迭代器.__next__()
# next(迭代器)
# 迭代器 = iter(可迭代的)
# 迭代器 = 可迭代的.__iter__() # range(10)
# range(1,11)
# print('__next__' in dir(range(1,11,2))) # dir 查看一个变量拥有的方法
# print(dir([]))
# print(dir(1)) # help
# help(str) # 变量
# print(callable(print))
# a = 1
# print(callable(a))
# print(callable(globals))
# def func():pass
# print(callable(func)) import time
# t = __import__('time')
# print(t.time()) # 某个方法属于某个数据类型的变量,就用.调用
# 如果某个方法不依赖于任何数据类型,就直接调用 —— 内置函数 和 自定义函数 # f = open('1.复习.py')
# print(f.writable())
# print(f.readable()) #id
#hash - 对于相同可hash数据的hash值在一次程序的执行过程中总是不变的
# - 字典的寻址方式
# print(hash(12345))
# print(hash('hsgda不想你走,nklgkds'))
# print(hash(('1','aaa')))
# print(hash([])) # ret = input('提示 : ')
# print(ret) # print('我们的祖国是花园',end='') #指定输出的结束符
# print('我们的祖国是花园',end='')
# print(1,2,3,4,5,sep='|') #指定输出多个值之间的分隔符
# f = open('file','w')
# print('aaaa',file=f)
# f.close() # import time
# for i in range(0,101,2):
# time.sleep(0.1)
# char_num = i//2
# per_str = '\r%s%% : %s\n' % (i, '*' * char_num) \
# if i == 100 else '\r%s%% : %s' % (i,'*'*char_num)
# print(per_str,end='', flush=True)
#progress Bar # exec('print(123)')
# eval('print(123)')
# print(eval('1+2+3+4')) # 有返回值
# print(exec('1+2+3+4')) #没有返回值
# exec和eval都可以执行 字符串类型的代码
# eval有返回值 —— 有结果的简单计算
# exec没有返回值 —— 简单流程控制
# eval只能用在你明确知道你要执行的代码是什么 # code = '''for i in range(10):
# print(i*'*')
# '''
# exec(code) # code1 = 'for i in range(0,10): print (i)'
# compile1 = compile(code1,'','exec')
# exec(compile1) # code2 = '1 + 2 + 3 + 4'
# compile2 = compile(code2,'','eval')
# print(eval(compile2)) # code3 = 'name = input("please input your name:")'
# compile3 = compile(code3,'','single')
# exec(compile3) #执行时显示交互命令,提示输入
# print(name)
# name #执行后name变量有值
# "'pythoner'" # 复数 —— complex
# 实数 : 有理数
# 无理数
# 虚数 :虚无缥缈的数
# 5 + 12j === 复合的数 === 复数
# 6 + 15j # 浮点数(有限循环小数,无限循环小数) != 小数 :有限循环小数,无限循环小数,无限不循环小数
# 浮点数
#354.123 = 3.54123*10**2 = 35.4123 * 10
# f = 1.781326913750135970
# print(f) # print(bin(10))
# print(oct(10))
# print(hex(10)) # print(abs(-5))
# print(abs(5)) # print(divmod(7,2)) # div出发 mod取余
# print(divmod(9,5)) # 除余 # print(round(3.14159,3))
# print(pow(2,3)) #pow幂运算 == 2**3
# print(pow(3,2))
# print(pow(2,3,3)) #幂运算之后再取余
# print(pow(3,2,1)) # ret = sum([1,2,3,4,5,6])
# print(ret) # ret = sum([1,2,3,4,5,6,10],)
# print(ret) # print(min([1,2,3,4]))
# print(min(1,2,3,4))
# print(min(1,2,3,-4))
# print(min(1,2,3,-4,key = abs)) print(max([1,2,3,4]))
print(max(1,2,3,4))
print(max(1,2,3,-4))
print(max(1,2,3,-4,key = abs))
python基础一 day15 内置函数的更多相关文章
- python 基础篇 15 内置函数和匿名函数
------------------------>>>>>>>>>>>>>>>内置函数<<< ...
- python基础 (装饰器,内置函数)
https://docs.python.org/zh-cn/3.7/library/functions.html 1.闭包回顾 在学习装饰器之前,可以先复习一下什么是闭包? 在嵌套函数内部的函数可以使 ...
- python基础之常用内置函数
前言 python有许多内置的函数,它们定义在python的builtins模块,在python的代码中可以直接使用它们. 常用的内置函数 类型转换 int python的整数类型都是int类型的实例 ...
- Python基础学习五 内置函数
1.函数补充: 1)函数返回值return可以有多个 2)补充示例: nums = [0,1,2,3,4,5,6,7,8] #如何将list里面的元素变为字符串类型 new_nums = [str(x ...
- python基础学习笔记——内置函数
一. 简介 python内置了一系列的常用函数,以便于我们使用,python英文官方文档详细说明:点击查看, 为了方便查看,将内置函数的总结记录下来. 二. 使用说明 以下是Python3版本所有的内 ...
- Python 基础之常用内置函数
1.常用内置函数 (1)abs 绝对值函数 intvar = -9 res = abs(intvar)print(res) (2)round 四舍五入 (n.5 n为偶数则舍去 n.5 n为奇数 ,则 ...
- python基础学习Day14 内置函数 匿名函数
一.内置函数里几个高频重要函数 (1)min\max函数的用法 以min函数的为例: min:返回可迭代对象的最小值(可加key,key为函数名,通过函数的规则,返回最小值). l1 =[(,),(, ...
- Python基础-常用的内置函数
内置函数filter str = ['a', 'b', 'c', 'd'] def fansik(num): if num != "a": return num ret = fil ...
- python 基础知识-day6(内置函数)
1.sorted():用于字典的排序 dict1={"name":"cch","age":"3","sex&q ...
随机推荐
- GridView_RowDataBound 常用方法
1.这个就不用说,鼠标经过行颜色变化 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { ...
- 多列组合为主键(PRIMARY KEY)
在表中,想把其中2列或多列作为组合主键. CREATE TABLE [dbo].[T3] ( ) NOT NULL, ) NOT NULL, ) NULL, ) NULL ) GO ALTER TAB ...
- unite2017相关
日程 http://unite2017.csdn.net/ http://www.sohu.com/a/137202360_280780 http://www.gameres.com/750046.h ...
- 洛谷 P5162 WD与积木【多项式求逆】
设f[i]为i个积木能堆出来的种类,g[i]为i个积木能堆出来的种类和 \[ f[n]=\sum_{i=1}^{n}C_{n}^{i}g[n-i] \] \[ g[n]=\sum_{i=1}^{n}C ...
- 2014-10-28 NOIP模拟赛
Porble 1时间与空间之旅(tstrip.*) 题目描述 公元22××年,宇宙中最普遍的交通工具是spaceship.spaceship的出现使得星系之间的联系变得更为紧密,所以spaceship ...
- springCloud学习总览
写完最后一篇特意去看了看第一篇是什么时候写的---2018/11/19,到现在三个月多一点,总的来说这三个月通过<Spring 微服务实战>这本书,算是对微服务进行了一次扫盲学习. ...
- python 之 包的使用
6.8 包的使用 包就是一个包含有init.py文件的文件夹,所以其实我们创建包的目的就是为了用文件夹将文件/模块组织起来 强调: 在python3中,即使包下没有__init__.py文件,impo ...
- Codeforces Round #566 (Div. 2)
Codeforces Round #566 (Div. 2) A Filling Shapes 给定一个 \(3\times n\) 的网格,问使用 这样的占三个格子图形填充满整个网格的方案数 如果 ...
- Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) C
Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n ...
- notepad++ 插件大全
Explorer 资源管理器 Colour Picker 拾色器 SecurePad 加密工具 HTMLTag NppExport 导出为特殊格式 Simple script AHKExtLe ...