py

作者: 周周周__ | 来源:发表于2020-12-09 11:02 被阅读0次
    获得当前的路径
    from pathlib import Path
    a = Path(__file__).absolute().parent   # 获得当前路径
    
    re.sub替换
    import re
    a = '123,456.000元'
    b = re.sub('(\d),(\d)', '\g<1>\g<2>', a) # b = 123456.000元
    
    
    时间
    import time
    now_time = time.strftime("%Y-%m-%d", time.localtime())  # '2020-12-17'
    now_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())  # '2020-12-17 15:36:36'
    
    
     db.name.getIndexes()
    db.name.createIndex({"Id":1},{unique: 1}) // 给字段添加索引
    db.name.createIndex({"create_time":1}) // 给字段添加索引
    
    db.collecionname.find().sort("UserName",pymongo.ASCENDING)   --升序
    db.collecionname.find().sort("UserName",pymongo.DESCENDING)  --降序
    
    # 遍历当前文件夹下边的xls
    file_path = r'C:\Users\admin\Desktop\company\ruanzhu\未'
    file_name_list = os.listdir(file_path)
    for file_name in file_name_list:
        print(file_name)
        path = file_path + '\\' + file_name
        data_a = xlrd.open_workbook(path)
        table = data_a.sheets()[0]
        nrowsa = table.nrows
        for i in range(1, nrowsa):
            item = table.row_values(i, start_colx=0, end_colx=None)
    
    from yarl import URL
    url = "https://www.qcc.com/web/charts/company-chart?keyNo=39f498af6581ce9e79dbe0a0408299a0&name=%E5%B9%BF%E5%B7%9E%E4%B8%AD%E5%BA%B7%E8%B5%84%E8%AE%AF%E8%82%A1%E4%BB%BD%E6%9C%89%E9%99%90%E5%85%AC%E5%8F%B8&uinfo=%5B1,1,1,1,1,1,1,1,1%5D"
    a = URL(url)
    print(a)
    print(a.host)
    print(a.name)
    print(a.raw_path)
    print(a.query)
    print(a.update_query('uinfo=123'))
    
    

    相关文章

      网友评论

          本文标题:py

          本文链接:https://www.haomeiwen.com/subject/moxhgktx.html