• 内置函数


    '''
    内置函数,不需要导入任何模块就可以使用的函数
    '''
    print(bytearray('长大的',encoding='utf-8'))
    '''
    转成字节
    '''
    print(callable(abs(1)))
    '''
    是否可以执行
    '''
    print(chr(int(101)))
    '''
    将一个数字转换成ascill码里面的字符
    chr一般和ord一起用,
    ord是将ascill里面的字符转换成数字,使用场景多为动态验证码
    '''
    print(ord(str('a')))
    li=['a','b','c']
    for i in li:
    print(i)
    for i in enumerate(li,0):
    print(i)
    '''
    enumerate,额外增加一列,进行序列的增加
    '''

    '''
    eval使用场景,对于电子表格里面的东西,
    里面都是字符串,如果是普通方法,首先会进行split,
    eval会直接识别这些
    '''
    print(eval('6*8'))
    '''
    filter,map
    filter用来过滤的
    map用来做条件的
    '''
    s=[11,22,33,44]
    for i in s:
    i=i+100
    print(i)

    new_s=map(lambda x:x+100,s)
    '''
    map会循环后面的参数,每循环一次,
    就会将前面的函数执行一次,将执行的结果赋给返回值
    '''
    print(new_s)
    l=list(new_s)
    print(l)
    print('s',s)
    '''
    filter就会进行过滤,最终会得到新的数据,是对元数据的修改
    '''
    def func(a):
    a = int()
    if a > 10:
    return True
    else:
    return False
    print(filter(func,s))
    p=filter(func,s)
    print('p',list(p))
    '''
    hash会作为字典的key用的
    '''
    print(hex(100))
    reversed(s)
    print(s)
    print(round(9,1))
    x=[1,2,3]
    y=[4,5,6]
    print(zip(x,y))
    '''
    open中的b模式使用场景主要包括、
    在Python3中采用字符读
    tell表示指针的位置,tell是用字节来读的
    seek会指定指针,seek之前的数据不会被读写,如果出现seek插在如中文的中间,
    就会出现乱码的情况,会读写失败
    read会读取seek指针后面的数据
    truncate会进行切片,会直接修改文件,没有返回值
    '''
    f=open('test.log','w')
    f.write(
    '爱情sdfdf''hao'
    )
    f.close()
    p=open('test.log','r+')
    print(p.read(4))
    print(p.tell())
    print(p.seek(7))
    print(p.read())
    print(p.truncate(6))
    print('j',p.read())
    p.close()



    bytearray(b'xe9x95xbfxe5xa4xa7xe7x9ax84')
    False
    e
    97
    a
    b
    c
    (0, 'a')
    (1, 'b')
    (2, 'c')
    48
    111
    122
    133
    144
    <map object at 0x0055F790>
    [111, 122, 133, 144]
    s [11, 22, 33, 44]
    <filter object at 0x0055FDB0>
    p []
    0x64
    [11, 22, 33, 44]
    9
    <zip object at 0x0056A5A8>
    爱情sd
    6
    7
    dfhao
    6
    j





  • 相关阅读:
    Unity Shader 基础(3) 获取深度纹理
    Unity Shader 基础(1): RenderType & ReplacementShader
    【Unity游戏开发】AssetBundle杂记--AssetBundle的二三事
    【Unity游戏开发】马三的游戏性能优化自留地
    【Unity游戏开发】跟着马三一起魔改LitJson
    【年终总结】马三京沪漂流记之2019年总结
    【Unity游戏开发】接入UWA_GOT的iOS版SDK以后无法正常出包
    【马三沪漂浮生记】之见闻壹
    【Unity游戏开发】性能优化之在真机上开启DeepProfile与踩坑
    【马三北漂记】之终章
  • 原文地址:https://www.cnblogs.com/xwl65/p/5186379.html
Copyright © 2020-2023  润新知