小编man*_*i77的帖子

在Python中使输入可选

我试图从一个输入中获取两个变量,如下所示:

x, y = input().split()
print(x, y)
Run Code Online (Sandbox Code Playgroud)

但我想让y变量可选,所以如果用户只输入x它只会打印该值.我得到一个ValueErrorif只插入x参数.

谁知道怎么做?

python python-3.x

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

如何在mysql服务器8 docker-compose文件中使用custom.cnf?

尝试在 docker-compose mysql 8 中使用自定义配置文件。 docker-compose.yml 看起来像

version: '3'
services:
  db:
    container_name: test-mysql8
    image: mysql/mysql-server:8.0
    volumes:
      - <host path to>/mycustom.cnf:/etc/mysql/conf.d/custom.cnf
    environment:
      - MYSQL_ROOT_PASSWORD=pass
      - MYSQL_DATABASE=testdb
      - MYSQL_USER=testuser
      - MYSQL_PASSWORD=testpassword
    ports:
      - "3306:3306"
    restart: always

  adminer:
    image: adminer:latest
    restart: always
    ports:
      - "8080:8080"
Run Code Online (Sandbox Code Playgroud)

以下是自定义配置文件 mycustom.cnf

[mysqld]
max_allowed_packet=32M
character-set-server=utf8
collation-server=utf8_bin
transaction_isolation=READ-COMMITTED
Run Code Online (Sandbox Code Playgroud)

运行docker-compose up -d并验证变量docker exec -it test-mysql8 bash

mysql -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8 …
Run Code Online (Sandbox Code Playgroud)

mysql docker docker-compose mysql-8.0

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

错误在条件表达式no-unneeded-ternary中不必要地使用布尔文字

我正在使用ESLintatom中尝试此代码

代码段:

$scope.IsVisible = false;
$scope.ShowHide = function () {
  $scope.IsVisible = $scope.IsVisible ? false : true; // error
};
Run Code Online (Sandbox Code Playgroud)

得到此ESLint错误:错误在条件表达式no-unneeded-ternary中不必要地使用布尔文字

尝试使用这些解决方案1解决方案2,但错误不是固定的.此外,代码在没有ESLint的编辑器中工作正常.

javascript ternary-operator angularjs eslint atom-editor

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