小编Ale*_*lex的帖子

什么是docker run -it flag?

我正在用docker做一些复杂的事情,但结果我不知道-it标志是什么意思.最近我遇到了一些令docker run我困惑的命令的例子.

docker run -itd ubuntu:xenial /bin/bash 
Run Code Online (Sandbox Code Playgroud)

我的问题是-it,如果在实例化期间运行容器,那么在这里写标志是有意义的bin/bash

在文档中我们有一个例子

docker run --name test -it debian
Run Code Online (Sandbox Code Playgroud)

有解释

-it指示Docker分配连接到容器的stdin的伪TTY; 在容器中创建交互式bash shell.

和帮助页面中-t标志的说明

-t, - try分配伪TTY

如果我删除-it标志期间

docker run -d ubuntu:xenial /bin/bash
Run Code Online (Sandbox Code Playgroud)

我新创建的容器并没有那么多

docker ps -a

它被指定为退出

对不起,如果我的问题很愚蠢,我在互联网上找不到解释(我对这一点有很大的误解).

docker dockerfile

64
推荐指数
4
解决办法
3万
查看次数

使用smb协议python3访问服务器上的远程文件

我有一些文件的远程服务器。

smb://ftpsrv/public/
Run Code Online (Sandbox Code Playgroud)

我可以作为匿名用户在那里获得授权。在 java 中,我可以简单地编写以下代码:

SmbFile root = new SmbFile(SMB_ROOT);

并获得处理内部文件的能力(这是我所需要的,一行!),但我找不到如何在 Python 3 中管理此任务,有很多资源,但我认为它们不是与我相关,因为它们经常针对 Python 2 和旧的其他方法量身定制。有没有一些简单的方法,类似于上面的Java代码?或者,例如,如果我想访问文件夹中的文件fgg.txt, 有人可以提供真正可行的解决方案smb://ftpsrv/public/。真的有一个方便的库来解决这个问题吗?

以现场为例:

import tempfile
from smb.SMBConnection import SMBConnection

# There will be some mechanism to capture userID, password, client_machine_name, server_name and server_ip
# client_machine_name can be an arbitary ASCII string
# server_name should match the remote machine name, or else the connection will be rejected
conn = SMBConnection(userID, password, client_machine_name, server_name, use_ntlm_v2 = True)
assert conn.connect(server_ip, 139)

file_obj = …
Run Code Online (Sandbox Code Playgroud)

python smb python-3.x

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

GitHub GraphQL API解析JSON的问题

这有什么不对?

query='{ repositoryOwner(login : "ALEXSSS") { login repositories (first : 30){ edges { node { name } } } } }'

headers = {'Authorization': 'token xxx'}

r2=requests.post('https://api.github.com/graphql', '{"query": \"'+query+'\"}',headers=headers)

print (r2.json())
Run Code Online (Sandbox Code Playgroud)

我有

{'message': 'Problems parsing JSON', 'documentation_url': 'https://developer.github.com/v3'}
Run Code Online (Sandbox Code Playgroud)

但是下面这段代码可以正常工作

query1= '''{ viewer { login name } }'''  

headers = {'Authorization': 'token xxx} 

r2=requests.post('https://api.github.com/graphql', '{"query": \"'+query1+'\"}',headers=headers) 

print (r2.json())
Run Code Online (Sandbox Code Playgroud)

我试着改变字符串("on"或"with"等等),但它不起作用.

python github-api python-requests graphql

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

如何用其他语言单词的英文字母创建字符串?

我需要找到一种方法将某些语言的单词(转换后的)重写为英语。例如,??????(俄语)听起来像privet(英语)。

含义和语法无关紧要,但是我希望它具有更相似的发音。一切都应该使用Python,我努力地在互联网上查找并且没有找到好的方法。

例如,类似于以下内容:

translit("?? ?? ????????", "ru") = juu so beutiful

translit("???", "ru") = kar
Run Code Online (Sandbox Code Playgroud)

python translation nlp nltk

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

如何隐藏一些json作为回应?

我有基于spring-data-rest的模块.我得到了这个回复,例如@Entity User.

网址:

http://localhost:8080/Product/rest/users
Run Code Online (Sandbox Code Playgroud)

响应:

 {
      "_embedded" : {
        "users" : [ {
          "def" : "dmityushin",
          "delDate" : null,
          "displayDef" : "?????‚???€???? ?”?????‚?????? ???»?µ?????°?????????????‡",
          "email" : "dmitry.mityushin@megafon.ru",
          "naviDate" : "2015-10-21T12:54:08.559+0000",
          "naviUser" : "admin",
          "phone" : null,
          "pwd" : "266810e0707d7aeb8e838308aa248f3ea116e483",
          "_links" : {
            "self" : {
              "href" : "http://localhost:8080/ProductCatalog/rest/2/users/308"
            },
            "user" : {
              "href" : "http://localhost:8080/ProductCatalog/rest/2/users/308"
            },
            "pscUser" : {
              "href" : "http://localhost:8080/ProductCatalog/rest/2/users/308/pscUser"
            },
            "pscBranch" : {
              "href" : "http://localhost:8080/ProductCatalog/rest/2/users/308/pscBranch"
            }
          }
        }, {
          "def" : "grak",
          "delDate" : null,
          "displayDef" …
Run Code Online (Sandbox Code Playgroud)

spring json spring-mvc spring-data-jpa spring-data-rest

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

如何在 spring-mvc 中为 springfox(更准确的 springfox-swagger2)设置主机 url?

我有 spring-mvc 应用程序,我已经嵌入了 RestAPI。一切正常,我的 rest api 映射到/rest/*url 上。当我添加 SwaggerConfig 时,它已经开始识别我的控制器,但是当我在 swagger-ui(简化消费者与 api 交互的 gui 形式)中尝试时 在此处输入图片说明

我有 404 未找到状态。因为这个试过了 在此处输入图片说明 这不会对有效网址进行请求

http://localhost:8080/ProductCatalog/rest/branch?id=1
Run Code Online (Sandbox Code Playgroud)

尽管 SwaggerConfig 映射到正确的 url,因为我在写入时得到了这个 GUI 表示

http://localhost:8080/ProductCatalog/rest/swagger-ui.html
Run Code Online (Sandbox Code Playgroud)

根 url 上有应用程序的一个主要部分(这不是我工作的部分),我的部分映射在/rest/* 如何更改此“试用”网址上/rest/*?我的 SwaggerConfig

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket pscApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                //.groupName("PSC");
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("restService.com.websystique.springmvc"))
                .paths(PathSelectors.any())
                .build();
        //PathSelectors.regex("/api/.*")
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("RestApiOfPSC")
                .description("REST API for PSC.")
                .build();
    }
}
Run Code Online (Sandbox Code Playgroud)

我也指定了这个

@Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) …
Run Code Online (Sandbox Code Playgroud)

rest spring spring-mvc swagger springfox

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

运算符as和ClassCastException

我如何通过运营商在Kotlin中"打破继承" ClassCastException.例如 在此输入图像描述

我可以在运行时获得ClassCastException,同时应该正确编译它

classcastexception kotlin

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