![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python入门
-TianSF-
-
展开
-
itemgetter
from operator import itemgettercutting_dim = 1points = [(6,8), (1,2), (0, 0), (10, -5)]points.sort(key=itemgetter(cutting_dim))print(points) #[(10, -5), (0, 0), (1, 2), (6, 8)]原创 2019-10-14 13:00:55 · 2362 阅读 · 0 评论 -
learn python
#合并两个有序的链表a = [1, 3, 5, 7, 9]b = [2, 4, 6, 8, 10]def dfs(a, b): ret = [] if a and b: if a[0] < b[0]: ret.append(a[0]) del a[0] ret.extend(dfs(a, b)...原创 2019-04-13 00:04:38 · 103 阅读 · 0 评论 -
python str操作
strVal = []strVal.append(('->'.join(str(x) for x in [1, 100, 200])))print(strVal)# ['1->100->200']原创 2019-04-16 14:19:39 · 204 阅读 · 0 评论 -
python入门 list
l = [i*i for i in range(1, 6)]print(l)def change(x): return x*10 + 1l = list(map(change, l))print(l)l = [i*i for i in range(1, 6)]l = list(map(lambda x: x*10 + 1, l))print(l)[1, 4, 9...原创 2019-04-13 15:16:06 · 101 阅读 · 0 评论 -
scipy 绘制B样条
import numpy as npimport pylab as plfrom scipy import interpolatex_end = 2*np.pix = np.linspace(0, x_end, 10000)y = np.sin(x)# y = np.array([0, .15, 1, .5, 0, 1])# print(type(x))x_new = np.li...原创 2019-04-21 19:43:05 · 1890 阅读 · 0 评论 -
python入门 property
class Test: """第一个类""" i = 123 def __init__(self): self.__pri_data = 21 @property def pri_data(self): return self.__pri_data @pri_data.setter def pri...原创 2019-04-14 09:56:34 · 140 阅读 · 0 评论 -
python入门 装饰器
import timeimport mathdef print_time(func): def wrap(*args): # 为了能接收参数 t1 = time.time() res = func(*args) print("TIME", time.time() - t1) return res # 返回结果 ...原创 2019-04-22 22:55:34 · 91 阅读 · 0 评论