内置函数


内置函数大全:
    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. MyBatis笔记----报错Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ij34.model.UserMapper.selectUser

    信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@41cf53f9: startup ...

  2. 自动化测试基础篇--Selenium Xpath定位

    摘自https://www.cnblogs.com/sanzangTst/p/7458056.html 学习 什么是xpath? XPath即为XML路径语言,它是一种用来确定XML(标准通用标记语言 ...

  3. SpringBoot集成spring-data-jpa注入Bean失败

    当项目结构正常(spring管理的Bean在SrpingBoot启动类平级或下级,支持spring扫描时),实现类上加 @Service注解,在实现类中注入dao层的Bean时,项目无法启动,无法找到 ...

  4. [Hive_8] Hive 设计优化

    0. 说明 在 Hive 中,数据库是一个文件夹,表也是文件夹 partition,是一个字段,是文件 前提:在 Hive 进行 where 子句查询的时候,会将条件语句和全表进行比对,搜索出所需的数 ...

  5. cp 拷贝

    cp -a = cp -pdr p (preserve 保持)  复制时保持文件原有的属性(preserve) 模式 所有权 时间戳 d 连接文件 no dereference 复制时拷备连接文件的属 ...

  6. firefox浏览器 插件--【维基百科+谷歌翻译】高级应用之 带图翻译

    [维基词典+谷歌翻译]插件地址: https://addons.mozilla.org/zh-CN/firefox/addon/google-dictionary-and-google-t/?src= ...

  7. centos7 多网卡绑定bond0 之mod4

    什么是mod4 mod=4,即:(802.3ad) IEEE 802.3ad Dynamic link aggregation(IEEE 802.3ad 动态链接聚合) 特点:创建一个聚合组,它们共享 ...

  8. Nunit单元测试入门学习随笔(一)

    Nunit单元测试 一.插件安装与项目关联 选择工具~扩展和更新 点击联机~搜索Nunit安装图内三个插件 新建单元测试项目 勾选项目引用 二.Nunit学习 1.了解单元测试 单元测试在我的理解是测 ...

  9. 【项目 · Wonderland】需求规格说明书 · 终版

    [项目 · Wonderland]需求规格说明书 · 终版 Part 0 · 简 要 目 录 Part 1 · 流 程 / 分 工 Part 2 · 需 求 规 格 说 明 书 Part 1 · 流 ...

  10. TCP三次握手四次挥手过程详解

    http://blog.csdn.net/imilli/article/details/50620104 TCP头部: 其中 ACK   SYN  序号  这三个部分在以下会用到,它们的介绍也在下面. ...