find_convexhull.py

来自「P2P模拟器」· Python 代码 · 共 37 行

PY
37
字号
#!/usr/bin/env python"""find_convexhull.py"""import sys, convexhull, re, string# need to get a set of pointsif __name__ == '__main__':    try:        data = sys.argv[1]    except IndexError:        data = "sample.eps" #die?    # read the file    f=open(data, 'r')    P = []    l = f.readline()    while l != "":      #print l      s = re.split( '\s+', l, 2)      if s[0] != "#" and s[1] != "":        P.append((string.atof(s[0]), string.atof(s[1])))      l = f.readline()    f.close()    H = convexhull.convexHull(P)    for p in H:#	print '%f,%f' % (p[0],p[1])	print p[0], p[1]

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?