小编dmx*_*dmx的帖子

可以从python代码生成序列图吗?

我有大约 700 行代码。我必须写一个关于这段代码的小文档。在这个文档中,我计划用一个序列图来解释更多。像这样:在此处输入图片说明由于我有点懒,想知道是否有工具可以从代码生成此图。我不想失去我整个周末做这件事。

有人有什么想法可以帮助我吗?

谢谢。

python sequence-diagram

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

Python-发送电子邮件时出错(拒绝中继访问)

尝试使用python sendmail发送电子邮件时出现错误。这是我的python代码:(Pas d'objet)

#! /usr/bin/python

import smtplib

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

# me == my email address
# you == recipient's email address
me = "my@email.com"
you = "email@gmail.com"

# Create message container - the correct MIME type is multipart/alternative.
msg = MIMEMultipart('alternative')
msg['Subject'] = "Link"
msg['From'] = me
msg['To'] = you

# Create the body of the message (a plain-text and an HTML version).
text = "Hi!\nHow are you?\nHere is the link you wanted:\nhttp://www.python.org"
html …
Run Code Online (Sandbox Code Playgroud)

python email smtp

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

在javascript中格式化日期

我想要这种格式的日期:'%Y-%m-%dT%H:%M:%S+0000'.我写了一个函数,但仍然问自己是否有更好的方法来做到这一点.这是我的功能:

 function formatDate() {
     var d = new Date();
     var year = d.getMonth() + 1;
     var day = d.getDate();
     var month = d.getMonth() + 1;
     var hour = d.getHours();
     var min = d.getMinutes();
     var sec = d.getSeconds();
    var date = d.getFullYear() + "-" + (month < 10 ? '0' + month : month) + "-" +
         (day < 10 ? '0' + day : day) +
         "T" + (hour < 10 ? '0' + hour : hour) + …
Run Code Online (Sandbox Code Playgroud)

javascript date

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

Ubuntu 17.10上的Android工作室:AVD Nexus_5_API_22的模拟器进程被杀死

我在我的ubuntu上重新安装了android-studio 3.0.所有流程安装都没问题.现在,我创建了一个新项目.但是当我尝试运行时,我在控制台上得到了这个:

11/10 21:10:19: Launching app
Error while waiting for the device: The emulator process for AVD Nexus_5_API_22 was killed.
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

请问有什么想法吗?

更新 这里是模拟器日志:

Executing tasks: [:app:assembleDebug]
Emulator: libGL error: unable to load driver: i965_dri.so
Emulator: libGL error: driver pointer missing
Emulator: libGL error: failed to load driver: i965
Emulator: libGL error: unable to load driver: i965_dri.so
Emulator: libGL error: driver pointer missing
Emulator: libGL error: failed to load driver: i965
Emulator: libGL error: unable to load driver: swrast_dri.so
Emulator: libGL …
Run Code Online (Sandbox Code Playgroud)

android android-studio

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

Angular 6:如何根据滚动突出显示导航栏上的元素?

我正在 Angular 6 中制作一个页面。它是一个简单的页面,我想navbar根据滚动来突出显示。

这是我的代码:

.sticky {
  position: sticky;
  top: 0;
}
#i ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: blue;
}

#i li {
  float: left;
}

#i li a {
  display: block;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

#i li a:hover {
  border-radius: 0px 0px 10px 10px;
  background-color: rgb(43, 137, 226);
}

/* #i {
  margin: 0px 0px 40px 0px;
} */

#footer-id {
  background-color:blue;
}
Run Code Online (Sandbox Code Playgroud)
<span id="i"> …
Run Code Online (Sandbox Code Playgroud)

html css typescript angular

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

Python:查明另一个应用程序是否打开文件的有效方法

我想通过 Python 脚本查找应用程序是否打开了文件。我知道有很多提议,但似乎没有一个完全符合我的要求。我已经尝试了很多解决方案。但仍然无法获得预期的行为。我想要的是当 python 脚本尝试打开由 pdf 阅读器打开的文件时引发异常。例如,如果我使用 pdf 阅读器打开一个文件,并尝试通过 Python 脚本打开/重命名它,它应该引发异常。我尝试了多段代码:

try:
    myfile = open("myfile.csv", "r+") # or "a+", whatever you need
except IOError:
    print "Could not open file! Please close Excel!"

with myfile:
    do_stuff()
Run Code Online (Sandbox Code Playgroud)

在这个问题中,我测试了很多脚本,但没有一个完美运行。当我重命名 pdf 文件时,即使它打开,重命名也是接受者并在最后。

这让我想知道这是不可能的还是我做错了。

python

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

错误-Docker-compose / docker Windows

我想在Windows系统上部署我的应用程序。我最近(昨天)安装DockerToolbox-1.12.4在Windows 10上。这为我提供了一个新终端。当我尝试使用部署我的项目时docker-compose up --build,我收到以下消息:

  1. ERROR: for myservice Cannot create container for myService: create \var\run\docker.socker: "\\var\\run\\docker.sock" includes invalid characters for a local volume name, only "[...][...]" are allowed 该服务包含

另一个错误是:

  1. ERROR: for service2 Cannont create container for service service2: Invalid bind mount spec "c:\\Users\\username\\Desktop\\project\\service2:/home/docker/code:rw" Encountered errors while bringing up projet。我的项目有4个容器,而其他2个没有错误消息。

这是我的docker-compose.yml文件:

version: '2'
services:
  s1:
    build: ../images/s1
    ports:
     - "5000:5000"
    links: ["s2"]
  s2:
    build: ../images/s2
    ports:
     - "9000:9000"
  service2:
    build: ../images/service2
    ports:
     - "4000:4000"
    volumes:
      - …
Run Code Online (Sandbox Code Playgroud)

windows docker docker-compose

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

为什么“docker Attach”不起作用并阻止我在 ubuntu 上的 konsole

基本上,我有一个正在运行的容器,我想在其上附加控制台。我曾经用来docker run -p 8080:80 test启动我的容器。看起来运行良好。

我的 docker ps 看起来像这样:

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                            NAMES
81b27e2525f1        test            "/bin/sh -c /start.sh"   13 minutes ago      Up 13 minutes       8080/tcp, 0.0.0.0:8080->80/tcp   vigilant_bassi
Run Code Online (Sandbox Code Playgroud)

然后尝试连接我的控制台

user@user:~$ docker attach 81b27e2525f1 
    ls  
    ^C
    
    
    
    ls
    ^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[B^[[B^[[B^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^C^C^C^C^[[A^[[A^[[A^[[A^[[A
Run Code Online (Sandbox Code Playgroud)

这不起作用,我无法分离。
然后我认为这是我尝试在新设备上打开的一个错误,并且我遇到了完全相同的问题。现在我有多个控制台被阻止。我发现这个问题,这不是同一个问题。

我究竟做错了什么?

ps我的docker版本是:Docker version 1.13.1, build 092cba3

docker

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

如何使用nodemon运行python 3?

我在 python 3 中有一个简单的脚本。我想与 nodemon 一起运行,以便它可以在文件更改时自动启动。在nodemon npm 上,我有以下代码:nodemon --exec "python -v" ./app.py。问题是 python 版本 3 并未强制执行。

我的 python 文件如下所示:

#!/usr/bin/env python3
print "hello world!"
Run Code Online (Sandbox Code Playgroud)

这段代码运行完美,这意味着 Python 3 没有被强制执行。

如何使用 nodemon 并确保它使用 Python 3 而不是 2?

python-3.x nodemon

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

如何开始使用dockerode

我正计划在docker中运行我的应用程序。我想在Docker容器上动态启动,停止,构建,运行命令.... 我找到了一个名为dockerode的工具。是项目存储库。这个项目有文档,但是我不太了解。我想了解几件事。这是建立图像的方法

docker.createContainer({Image: 'ubuntu', Cmd: ['/bin/bash'], name: 'ubuntu-test'}, function (err, container) {
  container.start(function (err, data) {
    //...
  });
});
Run Code Online (Sandbox Code Playgroud)

可以RUN apt-get update在使用Dockerfile时或RUN ADD /path/host /path/docker在构建过程中使像吗?构建后如何将我的应用程序移入容器?

让我们看一下这段代码:

//tty:true
docker.createContainer({ /*...*/ Tty: true /*...*/ }, function(err, container) {

  /* ... */

  container.attach({stream: true, stdout: true, stderr: true}, function (err, stream) {
    stream.pipe(process.stdout);
  });

  /* ... */
}
Run Code Online (Sandbox Code Playgroud)

我怎么知道我可以在这里放几个参数{ /*...*/ Tty: true /*...*/ }

有人也尝试过这个软件包吗?请帮助我开始。

docker docker-compose

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

vim - 在 .vimrc 中设置时,python autoindent 无法正常工作

我的.vimrc文件有问题:我正确地编写了 python 代码。但我有缩进问题。当我把它放在我的 .vimrc 文件中时:

" indentation python
au BufNewFile,BufRead *.py
    \ set tabstop=4
    \ set softtabstop=4
    \ set shiftwidth=4
    \ set textwidth=79
    \ set expandtab
    \ set ts=4
    \ set sw=4
    \ set ai
    \ set autoindent
    \ set fileformat=unix
    \ set expandtab ts=4 sw=4 ai
Run Code Online (Sandbox Code Playgroud)

但只要一个Python文件打开,如果我运行set expandtab ts=4 sw=4 ai Vim将在选择代码和命中时正确启动缩进S-=。任何的想法?

python vim

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

javascript水平滚动文本

我想在我的应用程序上水平滚动.有多个例子,但我找到了一个符合我需要的例子.但是,当我尝试它时,它只是不能正常工作.请看,告诉我问题是什么:

<!DOCTYPE html>
<html>
<head>
<style>
div.marquee {
    white-space:no-wrap;
    overflow:hidden;
}
div.marquee > div.marquee-text {
    white-space:nowrap;
    display:inline;
    width:auto;
}
</style>
<script>
var marquee = $('div.marquee');
console.log(marquee);
marquee.each(function() {
    var mar = $(this),indent = mar.width();
    mar.marquee = function() {
        indent--;
        mar.css('text-indent',indent);
        if (indent < -1 * mar.children('div.marquee-text').width()) {
            indent = mar.width();
        }
    };
    mar.data('interval',setInterval(mar.marquee,1000/60));
});
</script>
</head>
<body>
<div class='marquee'>
    <div class='marquee-text'>
        Testing this marquee function
    </div>
</div>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

更新 控制台中没有错误: 在此输入图像描述

html javascript css

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

angularjs函数($ http,$ location,...)不起作用

我有一个简单的angularjs应用程序,我想发出http请求,但我真的不知道为什么它不工作.这是我的控制器:

(function () {
    'use strict';

        /**
        * @ngdoc function
        * @name app.controller:HomeCtrl
        * @description
        * # HomeCtrl
        * Controller of the app
        */

      angular.module('BlurAdmin.pages.dashboard')
      .controller('HomeCtrl', ['$scope', '$rootScope', '$stateParams', '$http', '$location', HomeCtrl ]);
        function HomeCtrl($scope, $http, $location) {
          $scope.samples = [['a', 'b', 'c'], ['d', 'e', 'f']];

        console.log($http);
        console.log($scope);
        console.log($location);
        console.log(window.location.hostname);
        $http.get(
          'http://localhost' +   ':7000/samples', 

          {}
        ).then(function(err, data){
          if (err){
            console.log(err);
          }
          console.log(data);
        },
        function(err, data){
        });

            var varApplist = this;
        }
    })();
Run Code Online (Sandbox Code Playgroud)

我的家庭主持人:

<div id="page-wrapper" ng-controller="HomeCtrl">
......
<div>
Run Code Online (Sandbox Code Playgroud)

在我的index.html中

当我尝试运行时,我遇到了这个错误: …

http angularjs

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