内置函数


内置函数大全:
    Built-in Functions    
abs() dict() help() min() setattr()
all() dir() hex() next() slice()
any() divmod() id() object() sorted()
ascii() enumerate() input() oct() staticmethod()
bin() eval() int() open() str()
bool() exec() isinstance() ord() sum()
bytearray() filter() issubclass() pow() super()
bytes() float() iter() print() tuple()
callable() format() len() property() type()
chr() frozenset() list() range() vars()
classmethod() getattr() locals() repr() zip()
compile() globals() map() reversed() __import__()
complex() hasattr() max() round()  
delattr() hash() memoryview() set()  

# print()
# input()
# len()
# type()
# open()
# tuple()
# list()
# int()
# bool()
# set()
# dir()
# id()
# str()
# print(locals())  #返回本地作用域中的所有名字
# print(globals()) #返回全局作用域中的所有名字
# global 变量
# nonlocal 变量 #迭代器.__next__() 等价于 # next(迭代器)
# def next(迭代器):
# 迭代器.__next__() # next() 等价于执行了这个方法 # 迭代器 = iter(可迭代的) #得到迭代器
# 迭代器 = 可迭代的.__iter__() #得到迭代器
# range(10)
# range(1,11)
# range(1,11,2)
# print('__next__' in dir(range(1,11,2))) #range(1,11,2)不是一个迭代器
# iter(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)) # 在后面加上()能被调用的返回 True
# import time
# print(time.time()) # time = __import__('time')
# print(time.time()) # 某个方法属于某个数据类型的变量,就用.调用
# 如果某个方法不依赖于任何数据类型,就直接调用 —— 内置函数 和 自定义函数 # f = open('1.复习.py', encoding='utf-8')
# print(f.read())
# print(f.writable()) #判断文件能不能写
# print(f.readable()) #判断文件能不能读
内存相关的:
 
#id #内存地址

#hash - 对于相同可hash数据的hash值在一次程序的执行过程中总是不变的
# - 字典的寻址方式
# print(hash(12345))
# print(hash('hsgda不想你走,nklgkds'))
# print(hash(('1','aaa')))
# print(hash([])) #不可哈希 字典的寻址方式: key必须是可哈希
  字典的寻址方式快


# ret = input('提示 : ')
# print(ret)
# print('我们的祖国是花园',end='')  #指定输出的结束符  (print默认换行)
# print('我们的祖国是花园',end='')
# print(1,2,3,4,5,sep='|') #指定输出多个值之间的分隔符

# f = open('file','w')
# print('aaaa',file=f) #默认打印到屏幕 file指定打印的文件
# f.close()

f = open('tmp_file','w')
print(123,456,sep=',',file = f,flush=True)

打印进度条:
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)
\r 可以把光标移动到行首但不换行
#progress Bar 研究进度条

def print(self, *args, sep=' ', end='\n', file=None): # known special case of print
"""
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
file: 默认是输出到屏幕,如果设置为文件句柄,输出到文件
sep: 打印多个值之间的分隔符,默认为空格
end: 每一次打印的结尾,默认为换行符
flush: 立即把内容输出到流文件,不作缓存
""" print源码剖析
												

python_内置函数1_42的更多相关文章

  1. python_内置函数

    #内置函数 #1.abs 获取绝对值 # abs(-10) # --->10 # # abs(10) # --->10 # # abs(0) # --->0 #2.all() 参数为 ...

  2. Python_内置函数2_44

    字符串类型代码执行: exec('print(123)') eval('print(123)') print(eval('1*2+3+4')) # 有返回值 print(exec('1+2+3+4') ...

  3. Python_内置函数和匿名函数

    楔子 在讲新知识之前,我们先来复习复习函数的基础知识. 问:函数怎么调用? 函数名() 如果你们这么说...那你们就对了!好了记住这个事儿别给忘记了,咱们继续谈下一话题... 来你们在自己的环境里打印 ...

  4. Python_内置函数之zip

    zip函数用于将可迭代的对象作为参数,将对象中的元素打包成一个个元祖,然后返回这些元祖组成的列表.如果各个迭代器的元素个数不一致,则返回列表长度与最短的对象相同. l1 = [1, 2, 3] l2 ...

  5. Python_内置函数之max

    源码: def max(*args, key=None): # known special case of max """ max(iterable, *[, defau ...

  6. Python_内置函数之map()

    map 会根据提供的函数对指定序列做映射. 代码如下: def square(x): return x ** 2 ret = map(square, [1, 2, 3, 4, 5]) # 计算列表各元 ...

  7. Python_内置函数之round的幺蛾子

    pycharm运行结果 1 ret = round(0.5) print(ret) >>> 0 ret1 = round(1.5) print(ret1) >>> ...

  8. Python_部分内置函数

    内置函数:可以直接调用的函数 all():传入的列表,元组,等等,只要一个为假,就为假(fales)(所有的都为真才为真) # None, {}:空字典, []:空列表, 0:零,():空集合,“”: ...

  9. Entity Framework 6 Recipes 2nd Edition(11-12)译 -> 定义内置函数

    11-12. 定义内置函数 问题 想要定义一个在eSQL 和LINQ 查询里使用的内置函数. 解决方案 我们要在数据库中使用IsNull 函数,但是EF没有为eSQL 或LINQ发布这个函数. 假设我 ...

随机推荐

  1. hive笔记:复杂数据类型-array结构

    array 结构 (1)语法:array(val1,val2,val3,…)  操作类型:array array类型的数据可以通过'数组名[index]'的方式访问,index从0开始: (2)建表: ...

  2. c复杂函数指针

    函数指针,函数的返回值是数组 int *(*(*fun)(int* a, int* b))[]; 上面的代码是声明一个函数指针,这个函数有2个int指针参数,返回值是指针,指向的是数组,数组里放的是i ...

  3. Informix数据库配置与连接

    1.环境 数据库版本:12.1 操作系统:Windows Server 2008 客户端:IBM Data Studio 4.1.3 2.配置 数据库安装后默认是无法远程访问的,需要修改sqlhost ...

  4. Lua-pb 升级到Lua5.3

    项目lua库升级到5.3版本后,最头疼的就是原先的一些第三方库原先只是基于lua5.1设计的,比如protobuff 相关的的. 之前项目引入Lua-pb 实现protobuf的解析和使用,但是这个库 ...

  5. JavaScript数据类型之布尔类型

    引言 布尔值指代真或假.开或关.是或否.这个类型只有两个值,保留字true和false.JavaScript程序中的比较语句的结果通常都是布尔值.布尔值通常用于JavaScript中的控制结构中. 真 ...

  6. hover效果的几种方式

    1.改变透明度 #share_wrap a{display: inline-block;width: 48px;height: 44px;background: url(/images/finance ...

  7. RandomAccess

    在List集合中,我们经常会用到ArrayList以及LinkedList集合,但是通过查看源码,就会发现ArrayList实现RandomAccess接口,但是RandomAccess接口里面是空的 ...

  8. UVA437-The Tower of Babylon(动态规划基础)

    Problem UVA437-The Tower of Babylon Accept: 3648  Submit: 12532Time Limit: 3000 mSec Problem Descrip ...

  9. Topshelf:一款非常好用的 Windows 服务开发框架 转发https://www.cnblogs.com/happyframework/p/3601995.html

    背景 多数系统都会涉及到“后台服务”的开发,一般是为了调度一些自动执行的任务或从队列中消费一些消息,开发 windows service 有一点不爽的是:调试麻烦,当然你还需要知道 windows s ...

  10. with as 加上 materialize hint 生成实质临时表

    WITH AS: 就是将一个子查询部分独立出来,有时候是为了提高SQL语句的可读性,有时候是为了提高SQL语句性能. 如果一个SQL语句中,某个表会被访问多次,而且每次访问的限制条件一样的话,就可以使 ...