小编Chr*_*las的帖子

Golang与LDAP通信

我正在尝试使用golang连接和验证用户ldap.

我正在使用带有以下示例代码的go-ldap-client:

package main

import (
    "log"
    "github.com/jtblin/go-ldap-client"
)

func main() {
    client := &ldap.LDAPClient{
        Base:         "dc=example,dc=com",
        Host:         "ldap.example.com",
        Port:         389,
        UseSSL:       false,
        BindDN:       "uid=readonlysuer,ou=People,dc=example,dc=com",
        BindPassword: "readonlypassword",
        UserFilter:   "(uid=%s)",
        GroupFilter: "(memberUid=%s)",
        Attributes:   []string{"givenName", "sn", "mail", "uid"},
    }
    # It is the responsibility of the caller to close the connection
    defer client.Close()

    ok, user, err := client.Authenticate("username", "password")
    if err != nil {
        log.Fatalf("Error authenticating user %s: %+v", "username", err)
    }
    if !ok {
        log.Fatalf("Authenticating failed for user %s", …
Run Code Online (Sandbox Code Playgroud)

ldap go

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

无法找到满足要求mysql-connector-python的任何下载

我正在尝试安装mysql-connector-python,我收到以下错误:

Could not find any downloads that satisfy the requirement mysql-connector-python==2.0.4 (from -r requirements.txt (line 2))
Cleaning up...
No distributions at all found for mysql-connector-python==2.0.4 (from -r requirements.txt (line 2))
Run Code Online (Sandbox Code Playgroud)

我遵循的步骤是:

virtualenv -p python3 env/
source env/bin/activate
pip3 install -r requirements.txt --allow-external mysql-connector-python
Run Code Online (Sandbox Code Playgroud)

requirements.txt包含以下内容:

beautifulsoup4==4.4.1
mysql-connector-python==2.0.4
requests==2.9.1
wheel==0.24.0
Run Code Online (Sandbox Code Playgroud)

怎么能克服这个问题?

virtualenv python-3.x mysql-connector-python

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

BeautifulSoup 不会使用 utf-8 以外的其他编码解析 xml

我可以读取以 .xml 开头的所有 xmls 文件,<?xml version="1.0" encoding="utf-8"?>但无法读取以.xml 开头的文件<?xml version="1.0" encoding="ISO-8859-1"?>

具体来说,我有两个文件:

xml_iso.xml :

<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
</note>
Run Code Online (Sandbox Code Playgroud)

xml-utf.xml :

<?xml version="1.0" encoding="utf-8"?>
<note>
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
</note>
Run Code Online (Sandbox Code Playgroud)

使用以下代码,我可以找到note文件的 ,utf-8但我无法在其他编码的文件中找到它。我该如何解决?

示例代码:

import unittest

from bs4 import BeautifulSoup as Soup

class TestEncoding(unittest.TestCase):
    def test_iso(self):
        with open('tests/xml-iso.xml', 'r') as f_in:
            xml_soup = Soup(f_in.read(), 'xml')
        print('xml-iso:\n{}'.format(xml_soup))
        note = xml_soup.find('note')
        self.assertIsNotNone(note)

    def test_utf8(self):
        with open('tests/xml-utf.xml', 'r') as f_in:
            xml_soup = Soup(f_in.read(), 'xml')
        print('xml-utf8:\n{}'.format(xml_soup)) …
Run Code Online (Sandbox Code Playgroud)

xml encoding beautifulsoup python-3.x

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

OperationalError: (1054, “'field list' 中的未知列 'time_table.id'”)

我有一个不是由 django 创建的旧数据库,其中包含下表:

$ describe `time`; 
+---------------+--------------+------+-----+-------------------+-----------------------------+
| Field         | Type         | Null | Key | Default           | Extra                       |
+---------------+--------------+------+-----+-------------------+-----------------------------+
| data          | varchar(16)  | NO   | MUL | NULL              |                             |
| source        | varchar(255) | NO   |     | NULL              |                             |
| source_origin | varchar(128) | YES  |     | NULL              |                             |
| sys_updated   | timestamp    | NO   |     | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
+---------------+--------------+------+-----+-------------------+-----------------------------+
Run Code Online (Sandbox Code Playgroud)

我通过以下方式获得了这张表的模型inspectdb

class Time(models.Model):
    data = models.ForeignKey('a_table', models.DO_NOTHING)
    source …
Run Code Online (Sandbox Code Playgroud)

mysql django django-rest-framework

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

您的偏好无法阅读

每次打开镀铬时我都会遇到问题.我收到错误消息:

Your preferences cannot be read.

Some features may be unavailable and changes to preferences won't be saved.

因此,我必须在每次重新开始时登录chrome.

我在网上搜索并重新安装chrome的解决方案对我不起作用.我发现问题是丢失的文件夹,但我不知道是谁.

我的操作系统是Windows 8.任何帮助克服我的问题都是非常感谢.

windows google-chrome

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