小编cow*_*ert的帖子

Python:为什么"〜"现在包含在urllib.parse.quote()中的保留字符集中?

近期的文件urllib中指出:

在版本3.7中更改:从RFC 2396移至RFC 3986以引用URL字符串."〜"现在包含在保留字符集中.

为什么会这样?在RFC 3986中,~不是保留字符:

 reserved    = gen-delims / sub-delims

 gen-delims  = ":" / "/" / "?" / "#" / "[" / "]" / "@"

 sub-delims  = "!" / "$" / "&" / "'" / "(" / ")"
             / "*" / "+" / "," / ";" / "="
Run Code Online (Sandbox Code Playgroud)

明确地在下一节中,它被包含为一个未保留的字符:

2.3.未保留的角色

URI中允许但没有保留目的的字符称为unreserved.这些包括大写和小写字母,十进制数字,连字符,句点,下划线和波浪号.

 unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"
Run Code Online (Sandbox Code Playgroud)

此外,后来,RFC声明(强调我的):

例如,对应于波浪号(​​"〜")字符的八位字节通常由较旧的 URI处理实现编码为"%7E" …

python urlencode python-3.x

11
推荐指数
1
解决办法
354
查看次数

如何在模板中访问django表单字段名称

我有一个模型表单,我想迭代模板中的表单字段,但同时,当我遇到某些字段时,有条件地渲染额外的html.目前我正在从字段名称中提取,field.html_name但我不确定这是否是最好的方式(它感觉到某种程度上的hackish,就像我应该使用getattr()过滤器或其他东西......).

{% for field in form %}
<div class="form-group">

    {{ field }}

    {% if field.html_name == "location" %}
      <!-- CUSTOM HTML HERE -->
    {% endif %}

</div>   
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

django django-forms

5
推荐指数
2
解决办法
1万
查看次数

即使添加到 curl-ca-bundle.crt,curl openssl 也无法验证 IIS 7 自签名证书

我在 Windows Server Enterprise 2008 上使用 IIS 7 来生成自签名证书以与 IIS 一起使用(基本上是一键式按钮)。

但是,即使我将此证书导出并将其添加到 Windows 客户端的 curl-ca-bundle.crt,它和 openssl.exe 都不会正确验证证书:

openssl s_client -CAfile curl-ca-bundle.crt -showcerts -connect myserver.ad.pri:443

CONNECTED(00000003)
depth=0 /CN=myserver.ad.pri
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 /CN=myserver.ad.pri
verify error:num=21:unable to verify the first certificate
verify return:1
---
Certificate chain
 0 s:/CN=myserver.ad.pri
   i:/CN=myserver.ad.pri
-----BEGIN CERTIFICATE-----
MIIDADCCAeigAwIBAgIQTi9gdBLdo6pJ1h4Zljr/wzANBgkqhkiG9w0BAQUFADAp
....
-----END CERTIFICATE-----
---
Server certificate
subject=/CN=myserver.ad.pri
issuer=/CN=myserver.ad.pri
---
No client certificate CA names sent
---
SSL handshake has read 924 bytes and written …
Run Code Online (Sandbox Code Playgroud)

iis curl openssl certificate self-signed

3
推荐指数
1
解决办法
3455
查看次数

Python sqlalchemy 调用存储过程

我试图调用stored procedurepython使用sqlalchemy。我的代码如下:

@database_connection_wrapper
def get_adv(connection):
    ''' get the adv using a stored proc from the database '''

    connection.callproc("GetAdvMedianTrailing30Days")
    results = list(connection.fetchall())
    print(results)
Run Code Online (Sandbox Code Playgroud)

我收到以下错误: AttributeError: 'pyodbc.Connection' object has no attribute 'callproc'

我按照官方文档上的说明进行操作,但这并没有什么区别。

我在 python 3.5

有不同的调用方式stored procedures吗?

python sqlalchemy pyodbc python-3.x

3
推荐指数
1
解决办法
3277
查看次数

how to read attributes for given DN in ldap3 (how to search with ldap3 if no filter)

If I already have an LDAP DN, how do I get the attributes for that DN with ldap3.Connection.search()? There is no other search criteria, I already have the DN...

I tried searching for dn attribute, but it returned no objects found. I also tried forcing search_filter to '', '()' or None and they all returned malformed filter string.

I also couldn't find a way to do this with the abstract Reader...

In ldapsearch you don't need to specify …

python ldap ldap3

3
推荐指数
1
解决办法
2865
查看次数

如何/在何处指定PyRFC中的Open SQL调用SAP RFC_READ_TABLE

如何使用PyRFC在RFC_READ_TABLE查询中指定Open SQL WHERE子句?

我正在尝试开始使用PyRFC让python从SAP中进行表格提取(在没有支持/合作基础团队的情况下).在从这个例子http://scn.sap.com/community/scripting-languages/blog/2012/11/04/revisiting-python-and-sap-with-pyrfc,他们使用:

pyrfc.Connector.call("RFC_READ_TABLE", QUERY_TABLE=table, DELIMITER='|')
Run Code Online (Sandbox Code Playgroud)

http://saplsmw​​.com/node/101表示需要将WHERE子句作为OPTION传递给RFC调用.我怎么在PyRFC中这样做?(OPTIONS是SAP端的RFC_READ_TABLE函数模块声明中的类型表的导出变量).

编辑:好的http://scn.sap.com/community/scripting-languages/blog/2014/05/05/python-for-basis具有发送期权WHERE子句的例子:

OPTIONS = [{'TEXT':source_where}])
Run Code Online (Sandbox Code Playgroud)

所以看起来语法是单个元素字典的数组(映射SAP表类型),其中键是SAP数据类型,值是WHERE子句.

接下来的问题是:如何指定要发送到RFC_READ_TABLE的PACKAGE SIZE,以便我可以提取大型表而不会达到内部表限制?

python sql sap where-clause

2
推荐指数
1
解决办法
2676
查看次数