This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| from pdfminer.pdfparser import PDFParser, PDFDocument | |
| from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter | |
| from pdfminer.converter import PDFPageAggregator | |
| from pdfminer.layout import LAParams, LTTextBox | |
| from pdfminer.pdfinterp import PDFTextExtractionNotAllowed | |
| path = "xxx.pdf" | |
| # 用文件对象来创建一个pdf文档分析器 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import abc | |
| class Animal(metaclass=abc.ABCMeta): | |
| @abc.abstractmethod | |
| def screaming(self): | |
| 'Return when animal screaming the sound hear likes' | |
| return NotImplemented |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import functools | |
| from typing import List | |
| class Solution(object): | |
| def largest_nums(self, nums: List[int]) -> str: | |
| snums = [str(item) for item in nums] | |
| snums.sort(key=functools.cmp_to_key(self.cmp), reverse=True) | |
| _res = "" | |
| for i in snums: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| code = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'a', 'b', 'c', 'd'] | |
| # todo unicode 可以简化这个书写 62个[0-9,a-z,A-Z] 乱序可以制作一个混淆 算是加密算法 | |
| def ten2n(x, n): | |
| b = [] | |
| while True: | |
| j = x // n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from copy import deepcopy | |
| d1 = {1: 1, 2: 2} | |
| def change_dict_in_loop(): | |
| d_copy = deepcopy(d1) | |
| for k, v in d1.items(): | |
| d_copy.pop(1, None) | |
| return d_copy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import decimal | |
| import time | |
| from functools import reduce | |
| import matplotlib.pyplot as plt | |
| import random | |
| # generate scale number | |
| def scale_random_number(scale): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import openpyxl | |
| if __name__ == '__main__': | |
| wb = openpyxl.load_workbook('xxxx.xls') | |
| sheet = wb.get_sheet_by_name('审计报告') | |
| names = [cell.value for cell in sheet[0]] | |
| print(names) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bcrypt | |
| def get_hashed_password(plain_text_password): | |
| return bcrypt.hashpw(plain_text_password, bcrypt.gensalt()) | |
| def check_password(plain_text_password, hashed_password): | |
| return bcrypt.checkpw(plain_text_password, hashed_password) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| from typing import List | |
| test_case = [2, 1, 3, 8, 0] | |
| def insert_sort(l: List[int]) -> List[int]: | |
| if l is []: | |
| return [] | |
| length = len(l) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| shape = lambda n, m, default: [[default for _ in range(n)] for _ in range(m)] | |
| a = shape(2, 3, 0) | |
| print(a) | |
| a[0][1] = 2 | |
| print(a) | |
| """ | |
| [[0, 0], [0, 0], [0, 0]] | |
| [[0, 2], [0, 0], [0, 0]] |