我正在尝试使用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) 我正在尝试安装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)
怎么能克服这个问题?
我可以读取以 .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) 我有一个不是由 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) 每次打开镀铬时我都会遇到问题.我收到错误消息:
Your preferences cannot be read. Some features may be unavailable and changes to preferences won't be saved.
因此,我必须在每次重新开始时登录chrome.
我在网上搜索并重新安装chrome的解决方案对我不起作用.我发现问题是丢失的文件夹,但我不知道是谁.
我的操作系统是Windows 8.任何帮助克服我的问题都是非常感谢.