为了匹配Python 中的Unicode字边界[如附件#29中所定义],我一直在使用regex带有标志的包regex.WORD | regex.V1(regex.UNICODE应该是默认的,因为模式是Unicode字符串),方法如下:
>>> s="here are some words"
>>> regex.findall(r'\w(?:\B\S)*', s, flags = regex.V1 | regex.WORD)
['here', 'are', 'some', 'words']
Run Code Online (Sandbox Code Playgroud)
它在这个相当简单的情况下运行良好.但是,我想知道输入字符串包含某些标点符号时的预期行为是什么.在我看来,WB7说,例如撇号x'z不符合词边界,这似乎确实如此:
>>> regex.findall(r'\w(?:\B\S)*', "x'z", flags = regex.V1 | regex.WORD)
["x'z"]
Run Code Online (Sandbox Code Playgroud)
但是,如果有元音,情况会发生变化:
>>> regex.findall(r'\w(?:\B\S)*', "l'avion", flags = regex.V1 | regex.WORD)
["l'", 'avion']
Run Code Online (Sandbox Code Playgroud)
这表明正则表达式模块实现WB5a了Notes部分标准中提到的规则.但是,这条规则还说行为应该与\u2019(右单引号)相同,我无法重现:
>>> regex.findall(r'\w(?:\B\S)*', "l\u2019avion", flags = regex.V1 | regex.WORD)
['l’avion']
Run Code Online (Sandbox Code Playgroud)
此外,即使使用"普通"撇号,连字符(或y)似乎表现为"非元音":
>>> regex.findall(r'\w(?:\B\S)*', "l'œil", flags = regex.V1 | …Run Code Online (Sandbox Code Playgroud) 我有一个由两个点定义的LineString,因此本质上是一个直线段,我想在其上投影一个点。我知道.project和.interpolate。但是,当点在线段“外部”时,我不希望线段上最近的点,而是要扩展线段并绘制一条穿过该点并与(延伸的)线段正交的线。我想要投影的坐标。
例如,如果该点在“段内”
from shapely.geometry import Point
from shapely.geometry import LineString
point = Point(0.2, 0.5)
dist = LineString([(0, 1), (1, 1)]).project(point)
list(LineString([(0, 1), (1, 1)]).interpolate(dist).coords)
Run Code Online (Sandbox Code Playgroud)
任何人都知道该点在线段之外怎么办?
我已经通过Omnibus软件包在CentOS 7(全新安装)上安装了最新的Gitlab-CE(8.10),如下所述:https://about.gitlab.com/downloads/#centos7
现在,我想更改可以访问Gitlab Web界面的默认端口.为此,我按照http://docs.gitlab.com/omnibus/settings/nginx.html#change-the-default-port-and-the-ssl-certificate-locations中的说明进行操作,即包括
external_url "http://127.0.0.1:8765"
Run Code Online (Sandbox Code Playgroud)
在配置文件中/etc/gitlab/gitlab.rb,然后使用更新配置gitlab-ctl reconfigure && gitlab-ctl restart.
然而,当我然后导航到http://127.0.0.1:8765,Gitlab保持重定向到http://127.0.0.1/users/sign_in,即端口规范以某种方式被丢弃.当我手动将浏览器中的URL更改为时http://127.0.0.1:8765/users/sign_in,它会正确显示登录页面,有趣的是,页面上的所有链接(例如"Explore","Help")都包含端口规范.
为了解决这个问题,是否有必要在其他地方指定端口/etc/gitlab/gitlab.rb?
from shapely.geometry import Polygon, Point
p = Point(2,2)
poly = Polygon((0,0), (0,5), (5,0), (5,5))
print poly.contains(p)
Run Code Online (Sandbox Code Playgroud)
False尽管我确信(2,2)长度在一平方尺之内,但可以打印出来5。或者也许我只是不知道contains方法是如何工作的。p.within(poly)也回来了False。我是在Polygon正确使用类吗?还是我真的对几何不好?
python ×3
shapely ×2
gis ×1
gitlab ×1
point ×1
projection ×1
python-3.x ×1
regex ×1
unicode ×1