标签:es2017 fun compile hashlib pytho enc size flush pycharm
一共有68个内置函数:
#内置:python自带 # def func(): # a = 1 # b = 2 # print(locals()) # print(globals()) # func() # range(100) #[0,100) # range(5,100) #[5,100) # range(1,100,2) #可迭代对象,可以for循环,惰性运算 # range(100).__iter__() # iterator = iter(range(100)) #拿到一个迭代器 # print(iterator.__next__()) # print(next(iterator)) # for i in range(100): # print(i) # def iter(): # return range(100).__iter__() # print(dir([])) # print(dir(5)) # a = 1 # def func():pass # print(callable(a)) #不可以调用 # print(callable(print)) #可以调用 # print(callable(func)) #可以调用 #ctrl + 左键单击 :pycharm #help:包含所有方法名以及他的使用方法 —— 不知道用法 #dir:只包含方法名 —— 想查看某方法是否在这个数据类型中 import time #时间 import os #操作系统 # f = open(‘文件名‘,‘w‘,encoding=‘utf-8‘) #打开模式:r、w、a、rb、wb,ab #编码 utf-8/GBK # print(id(1)) # print(id(2)) # print(hash(‘sajghfj;eyrwodnvjnz,.jifupwk‘)) #算法 # print(hash(125342)) # print(hash((1,2,3,4))) #数据的存储和查找 #模块:hashlib # {‘k‘:‘v‘} # [1,2,3,4,5,6,] # hash([1,2,3,4,5,6,]) #hash 判断一个数据类型是否可以hash #在一个程序执行的过程中,对同一个值hash的结果总是不变 #多次执行,对同一个值的hash结果可能改变 # s = input(‘提示:‘) # print(1,2,3,4,5,sep=‘*‘) #sep是指定多个要打印的内容之间的分隔符 # print(1,2,sep=‘,‘) #print(‘%s,%s‘%(1,2)) # f = open(‘a‘,‘w‘) # print(‘abc\n‘) # print(2) # import time # for i in range(0,101,2): #[0,2,4,6,8...100] # time.sleep(0.2) # char_num = i//2 #打印多少个‘*‘ 8/2 = 4 # if i == 100: # per_str = ‘\r%s%% : %s\n‘ % (i, ‘|‘ * char_num) # else: # per_str = ‘\r%s%% : %s‘%(i,‘|‘*char_num) # print(per_str,end=‘‘, flush=True) # print(‘你好‘) # print(‘再见‘) #ftp == 网盘 # print("\033[31;1mHello world,how are you \033[0m") # print(‘\033[4;32;41m金老师‘) # print(‘egon‘) # print(‘alex \033[0m‘) # exec("print(‘12345‘)") # eval("print(‘12345‘)") # print(exec(‘1+2+3-4‘)) # print(eval(‘1+2+3-4‘)) # a = 1+2+3-4 # print(1+2+3-4) # code1 = ‘for i in range(0,10): print (i)‘ # compile1 = compile(code1,‘‘,‘exec‘) # exec(compile1) #简单求值表达式用eval # code2 = ‘1 + 2 + 3 + 4‘ # compile2 = compile(code2,‘‘,‘eval‘) # print(eval(compile2)) # code3 = ‘name = input("please input your name:")‘ # compile3 = compile(code3,‘‘,‘single‘) # # name #执行前name变量不存在 # exec(compile3) # print(name) #exec #eval #compile # print(abs(5)) # ret = divmod(10,2) #商余 # print(ret) # ret = divmod(3,2) # print(ret) # ret = divmod(7,2) # print(ret) # 107 # 10 # divmod(107,10) # print(round(3.14159,2)) # print(pow(2,3.5)) #幂运算 # print(pow(3,2)) # print(pow(2,3,2)) # print(pow(2,3,3)) #x**y%z # print(sum([1,2,3,4,5,6],-2)) # print(sum(range(100))) #sum接收一个可迭代对象 #min # print(min([1,4,0,9,6])) # print(min([],default=0)) print(min([-9,1,23,5],key=abs))#匿名函数 # print(min({‘z‘:1,‘a‘:2})) # t = (-25,1,3,6,8) # print(max(t)) # print(max(t,key = abs)) # print(max((),default=100))
内置函数未完待续。。。
标签:es2017 fun compile hashlib pytho enc size flush pycharm
原文地址:http://www.cnblogs.com/2012-dream/p/7811333.html