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 itertools import groupby | |
sep = ',!?:; :,.。!?《》、|\\/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' | |
eng_split_texts = [''.join(g) for k, g in groupby(self.eng_texts, sep.__contains__) if not k] |
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
select col from yourtable | |
order by cast(col as unsigned) |
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 sys import platform | |
if platform == "linux" or platform == "linux2": | |
# linux | |
elif platform == "darwin": | |
# OS X | |
elif platform == "win32": | |
# Windows... |
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
""" | |
将docx,doc文件转换成pdf的后缀,不考虑大小写 | |
""" | |
import re | |
doc_format_list=[r'.docx',r'.doc'] | |
doc_format_pattern='|'.join(doc_format_list) | |
path = r'C:\Users\Administrator\Desktop\temp\托书2 - Copy.DOCX' | |
print(re.sub(doc_format_pattern, r'.pdf', path, flags=re.I)) |
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
# 获取python解释器的位数 | |
import struct | |
print(struct.calcsize("P") * 8) |
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 glob | |
file_list = [] | |
for ext in ('*.pdf', '*.PDF'): | |
res_paths = os.path.join(directory, ext) | |
file_list.extend(glob.glob(res_paths)) | |
for file in file_list: | |
pass |
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 sklearn.datasets import load_iris | |
from sklearn.linear_model import LogisticRegression | |
from sklearn.model_selection import train_test_split | |
import matplotlib.pyplot as plt | |
import numpy as np | |
# 加载数据集 | |
iris = load_iris() | |
# 数据特征:150行, 4列 |
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 matplotlib.pyplot as plt | |
import numpy as np | |
def sigmoid(x): | |
return 1. / (1. + np.exp(-x)) | |
x = np.arange(-10, 10, 0.1) | |
y = sigmoid(x) | |
plt.plot(x, y) |
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import re | |
import os | |
import glob | |
# clone所有的仓库,如果仓库存在则更新 | |
def clone_all_project(): |
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 operator | |
x = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0} | |
sorted_x = sorted(x.items(), key=operator.itemgetter(1)) | |
import operator | |
x = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0} | |
sorted_x = sorted(x.items(), key=operator.itemgetter(0)) | |
x = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0} |