内置函数


内置函数大全:
    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. WinForm设置注册表自动启动

    string path = Application.StartupPath; SetAutoRun(path + @"\AppName.exe", true); /// <s ...

  2. 教你用Python Jupyter Notebook 制作代码分享 PPT

    PPT 是个强大的工具,但是笔者的 PPT 制作技术不咋地,所以之前的分享习惯使用 Jupyter Notebook + RISE,这样使用简单的 markdown 格式加上代码就足够做一次代码分享了 ...

  3. mysql文件

    MySQL的每个数据库都对应存放在一个与数据库同名的文件夹中,MySQL数据库文件包括MySQL(server)所建数据库文件和MySQL(server)所用存储引擎创建的数据库文件. .frm文件: ...

  4. PHP中Snoopy类的使用

    最近看PHP书籍,发现了一个好东东,就是Snoopy类.Snoopy是一个php类库,用来模拟浏览器的功能,可以获取网页内容,发送表单. Snoopy的一些特点: 1抓取网页的内容 fetch 2 抓 ...

  5. ASP.NET -- WebForm -- Session的使用

    ASP.NET -- WebForm --  Session的使用 Session是服务器端状态保持机制. 1. Test4.aspx文件与Test4.aspx.cs文件 <%@ Page La ...

  6. Spring的AOP开发入门,Spring整合Junit单元测试(基于ASpectJ的XML方式)

    参考自 https://www.cnblogs.com/ltfxy/p/9882430.html 创建web项目,引入jar包 除了基本的6个Spring开发的jar包外,还要引入aop开发相关的四个 ...

  7. Java操作Excel(使用JXL)

    一.本地操作 1.读取 package com.ljf.mb; import java.io.FileInputStream; import java.io.InputStream; import j ...

  8. 【shell脚本】shell脚本实现的 函数差集查找

    文本地址 点击关注微信公众号 wenyuqinghuai 分享提纲: 1. 问题背景 2. 代码实现 1.问题背景 在做公司的测试的自动化测试时,覆盖了一些开发代码的函数,但是那些还没有做,使用一个函 ...

  9. element ui Angular学习笔记(一)

    1.element ui安装 npm i --save element-angular 2.Angular-cli引入 引入后需要开启ElModule.forRoot(),也可以单独引入某个组件入El ...

  10. Python实现矿池

    自建P2POOL矿池详细教程(高级篇)http://8btc.com/article-1804-1.html p2pool比特币矿池教程综合篇(包含linux矿池教程)https://www.cybt ...