小编jac*_*118的帖子

docker容器不会以Mysql docker image开头

我将docker容器与mysql官方映像配合使用,以创建11个以上的数据库容器(container1到container11)。设置后,所有容器都可以正常运行,直到container9。在container10,它仅启动约1分钟,然后再次停止。使用码头工人日志来检查容器,但我什么也没看到。停止container9,然后重新启动container10。它再次运行正常。这种情况似乎仅在我有9个mysql容器并尝试提高第10个容器时发生。如果我停下其中一个,然后再抬起。那就没有问题了。是虫子吗?还是我错过了docker bridge的一些设置?

root@ec8dcb82f64d:/dev/shm# docker restart f4801b57c4cc
f4801b57c4cc
root@ec8dcb82f64d:/dev/shm# docker ps -a | grep f4801b57c4cc
f4801b57c4cc        mysql/mysql-server:5.7             "/entrypoint.sh my..."   2 weeks ago         Exited (1) 3 seconds ago                                                             db
root@ec8dcb82f64d:/dev/shm# docker logs f4801b57c4cc
Initializing database
Database initialized
MySQL init process in progress...
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the …
Run Code Online (Sandbox Code Playgroud)

docker docker-machine

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

Selenium Python maximize Chrome browser window size to make it fit with using screen size

How I can maximize chrome browser window size to make it fit with using screen size? I have tried doing that using the function driver.maximize_window(). It only maximize height but not width.

The version I'm using is: selenium-server-standalone-3.11.0.jar and python 3.6.4

Here's the code I'm using:

from selenium import webdriver
# get initial window size
driver = webdriver.Chrome()
print(driver.get_window_size())
# set window size
driver.set_window_size(480, 320)
print(driver.get_window_size())
# maximize window
driver.maximize_window()
print(driver.get_window_size())
driver.set_window_size(2560, 1440)
print(driver.get_window_size())
driver.quit()
Run Code Online (Sandbox Code Playgroud)

Output:

{'width': 1200, 'height': …
Run Code Online (Sandbox Code Playgroud)

python selenium selenium-chromedriver selenium-webdriver

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

将dataframe列值转换为数字数字

我的数据框列中有以下数据.如何通过数字转换每个域名?我尝试在for循环中使用replace.但是,由于我有超过1200个unqie域名.我不想这似乎不是一个想法的方法

for i, v in np.ndenumerate(np.unique(df['domain'])):
    df['domain'] = df['domain'].replace(to_replace=[v], value=i[0]+1, inplace=True)
Run Code Online (Sandbox Code Playgroud)

但它不起作用

data frame:
    type  domain
0    1     yahoo.com
1    1     google.com
2    0     google.com
3    0     aa.com
4    0     google.com
5    0     aa.com
6    1     abc.com
7    1     msn.com
8    1     abc.com
9    1     abc.com
....
Run Code Online (Sandbox Code Playgroud)

我想转换为

    type  domain
0    1     1
1    1     2
2    0     2
3    0     3
4    0     2
5    0     3
6    1     4
7    1     5
8    1     4
9    1     4 …
Run Code Online (Sandbox Code Playgroud)

numpy dataframe python-3.x pandas

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

如何从嵌套函数中为变量赋值

尝试了解如何从嵌套函数中为变量赋值。但它不起作用。是因为当我使用 时a = b,它认为 a 是嵌套函数的局部变量吗?那么如何为 func 中的 a 变量赋值呢?

def func():
    a = 0
    def nested(b):
        global a
        a = b
    nested(3)
    return a
print(func())
Run Code Online (Sandbox Code Playgroud)

python python-3.x

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

将字符串附加到打字稿中字符串数组中的每个元素

如何将字符串附加到打字稿中字符串数组中的每个元素我有一个数组,就像const original = ['a', 'b', 'c']我想要的那样,const original_string = ['i am key a', 'i am key b', 'i am key c']我该怎么做?也许是这样的const original_string = original.map(() => ${'i am key'})?我有以下但不起作用

const original_string = original.forEach((item)=> (`i am key ${item}`));
Run Code Online (Sandbox Code Playgroud)

typescript typescript2.0

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

创建具有多个工作表的谷歌工作表

我尝试使用 google 驱动器 api 在指定文件夹中创建 google 工作表。我的以下代码工作正常,但我想创建一个包含多个工作表的文件。我已经尝试过了properties。但是,它仍然显示为 Sheet1

file_metadata = {'properties': {'title': 'test title'}, 'name': 'google sheets filename', 'parents': [google_folder_id], 'mimeType': 'application/vnd.google-apps.spreadsheet', }
google_sheets_metadata = self.__service.files().create(body=file_metadata).execute()
Run Code Online (Sandbox Code Playgroud)

google-sheets python-3.x google-drive-api

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

变量: <type> 与打字稿中的变量 <type>

我是打字稿新手,想知道两者之间有什么不同: <type> vs xxx as <type>?我怎么知道在哪里使用哪一个?

let abc: any = {}
let abc = {} as any
Run Code Online (Sandbox Code Playgroud)

typescript typescript1.8 typescript2.0

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

如何有条件地使用打字稿将useQuery放入react-query中

我正在使用useQueryfromreact-query来获取我只希望查询在某种条件下运行的数据。我该如何使用它?以下是我要使用的代码useQuery

  const query = useQuery<APIResponse, Error>(
    [{query: creatGQL, variables: variables}],
    async () => {
      const result: APIResponse = await ucFetch(apiUrl, {
        method: 'POST',
        headers: {'Content-Type': 'application/json'},
        body: JSON.stringify({
          query: creatGQL,
          variables: variables,
        }),
      });
      return result;
    }  );
  return query;
Run Code Online (Sandbox Code Playgroud)

typescript reactjs react-query

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

使用 == 比较 python 中的两个 Counter 对象

我有两个字符串,我想比较彼此匹配的字符数。我想到的方法是使用 collections.Counter 构建一个以字符为键、显示频率为值的 Counter 对象,然后使用==来比较是否匹配。但我的问题是,用于==比较两个 Counter 对象是否有效?比较每个键和值是否都相同?

前任:

string_one = 'aaaaab'
string_two = 'aabaaa'
Counter(string_one) == Counter(string_two) # should be True

string_one = 'aaaaab'
string_two = 'aabaac'
Counter(string_one) == Counter(string_two) # should be False
Run Code Online (Sandbox Code Playgroud)

python

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

如何在多个条件下断言一次?

如何使以下代码更加 Pythonic?所以我可以将 if/else 和 2 assert 语句合并为一行?

@pytest.mark.parametrize('para', [1, -1, 0])
def test_xxxx(self, para):
    def test(value):
        return False if value >= 0 else True

    if para >= 0:
        assert test(para) is False
    else:
        assert test(para) is True
Run Code Online (Sandbox Code Playgroud)

python pytest

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

使用 selenium wait waiting 等待 python 中的某些查询完成

我尝试使用 selenium 和 python3.x 在 UI 上编写流程。在某些情况下,我想等待特定查询完成后再进行下一步。因为在查询完成期间,没有我可以选择使用的元素,并且return document.readyStateascomplete对我不起作用。是否可以使用 selenium wait.until 来做到这一点?喜欢

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome()
WebDriverWait(driver, 120).until(lambda x: "query return 0")
WebDriverWait(driver, 120).until(EC."something to wait for")
Run Code Online (Sandbox Code Playgroud)

selenium python-3.x selenium-webdriver

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