小编Bor*_*yev的帖子

理解python的主要方法

我是Python新手,但我有其他OOPS语言的经验.我的课程没有解释python中的主要方法.

请告诉我python中main方法的工作原理?我很困惑,因为我试图将它与Java进行比较.

def main():
# display some lines

if __name__ == "__main__": main()
Run Code Online (Sandbox Code Playgroud)

主要如何执行,为什么我需要这个奇怪if的执行main.当我删除时,我的代码终止而没有输出if.

最小的代码 -

class AnimalActions:
    def quack(self): return self.strings['quack']
    def bark(self): return self.strings['bark']

class Duck(AnimalActions):
    strings = dict(
        quack = "Quaaaaak!",
        bark = "The duck cannot bark.",
    )


class Dog(AnimalActions):
    strings = dict(
        quack = "The dog cannot quack.",
        bark = "Arf!",
    )

def in_the_doghouse(dog):
    print(dog.bark())

def in_the_forest(duck):
    print(duck.quack())

def main():
    donald = Duck()
    fido = Dog()

    print("- In the forest:") …
Run Code Online (Sandbox Code Playgroud)

python python-3.x

146
推荐指数
4
解决办法
35万
查看次数

RSpec NoMethodError:"主要对象的未定义方法`描述"

我正在努力学习Rspec.我在Eclipse中的ruby项目如下 -

在此输入图像描述

代码-

require 'rspec'
require './RubyOffRailsTuts/classes/furlong'

describe Furlong do
end
Run Code Online (Sandbox Code Playgroud)

错误-

/RubyOffRailsTuts/specs/furlong_spec.rb:6:in `<main>': undefined 
method `describe' for main:Object (NoMethodError)
Run Code Online (Sandbox Code Playgroud)

没有在线获得任何有用的答案.我该如何解决这个问题?

ruby rspec

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

SSIS神秘的错误

将平面文件转换为数据库表时,我只得到了这两个错误.数据流似乎适用于具有相同布局的其他平面文件,因此我不明白这些错误可能来自何处.

[Flat File Source [204]] Error: An error occurred while skipping data rows.

[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  
The PrimeOutput method on Flat File Source returned error code 0xC0202091.  
The component returned a failure code when the pipeline engine called 
PrimeOutput(). The meaning of the failure code is defined by the component, 
but the error is fatal and the pipeline stopped executing.  There may be 
error messages posted before this with more information about the failure.
Run Code Online (Sandbox Code Playgroud)

sql-server ssis flat-file

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

Python代码有效,但eclipse显示错误 - 检测元组时出现语法错误

我是python的新手.我在Eclipse Kepler中使用Python 3.3.

这是我的代码片段:

f = Fibonacci(0,1)
for r in f.series():
    if r > 100: break
    print(r, end=' ')
Run Code Online (Sandbox Code Playgroud)

在该行print(r, end = ''),eclipse报告语法错误 - Syntax error while detecting tuple.但是,该程序运行完美.

为什么会发生这种情况,如何解决错误?

python eclipse python-3.x

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

Maven/mvn警告 - 强烈建议修复这些问题,因为它们会威胁到构建的稳定性

这个问题不是关于Spring框架或J2EE本身.

根据我的书,我在eclipse-jee中有一个Spring项目.它告诉我用maven构建项目.我是maven的新手,我不知道我在做什么.

所以,我使用windows cmd进入eclipse中的项目文件夹并执行mvn package -DskipTests.现在,这会成功显示一条BUILD SUCCESS消息,但它也会在下面给出警告.

请告诉我为什么会出现这些警告以及如何点燃这些警告会对我造成伤害?

[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for
com.perfmath.spring:soba:war:4
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be
 unique: org.apache.httpcomponents:httpclient:jar -> version 4.1.2 vs 4.0.3 @ li
ne 229, column 15
[WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:tomcat-maven-plug
in is missing. @ line 46, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten t
he stability of your build.
[WARNING]
[WARNING] For …
Run Code Online (Sandbox Code Playgroud)

java eclipse maven

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

如何在脚本中停止tail命令

我想做什么 - 使用自定义ssh客户端代码***开始将更改捕获到日志文件.经过一段时间(不是固定值并且基于事件),发出命令以停止拖尾.这是我用来捕获日志文件的最新更改的命令 - tail -f logfile.txt

我想能够用:q脚本发出的东西来结束它.我不想像键盘命令那样ctrl + c.

***我的自定义ssh客户端代码的伪代码(用oop语言编写)

include ssh-api
ssh = getSSHConnection();
cmd = 'cd to folder';
ssh.command(cmd);
cmd = 'tail -f log.txt';
ssh.command(cmd);
wait for special event to occur...
cmd = 'stop the tail now!'
out = ssh.command(cmd);
print "the changes made to log file were\n"  + out;
Run Code Online (Sandbox Code Playgroud)

我没有对日志文件所在服务器的写访问权限.

我尝试了什么 - http://www.linuxquestions.org/questions/red-hat-31/how-to-stop-tail-f-in-scipt-529419/

我无法理解那里的解决方案(在帖子2中).有人可以解释解决方案或建议采用不同的方法吗?

谢谢.

unix linux bash

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

@Basic注释真的有用吗?

看来@Basicjava变量上的注释只声明该变量必须保存为具有NOT NULL约束的列.那是对的吗 ?

这篇文章说的@Basic(optional = false) @Column(nullable = false) The @Basic annotation marks the property as not optional on the Java object level. The second setting, nullable = false on the column mapping, is only responsible for the generation of a NOT NULL database constraint. The Hibernate JPA implementation treats both options the same way in any case, so you may as well use only one of the annotations for this purpose.

我很迷惑.这意味着什么 - The …

java hibernate jpa

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

这在Java中 - 线程"main"java.lang.StackOverflowError中的异常

为什么我收到stackoverflow错误?

我的课 -

public class Tester {

int id;

 Tester(int id){
  this.id = id;
 }

 public String toString(){

  String rep = "Hex: " + this + ", Id: " + this.id;
  return rep;
 }

}
Run Code Online (Sandbox Code Playgroud)

主要方法 -

class Driver{

    public static void main(String [] args){

        Tester t = new Tester(123);
        System.out.println(t);

    }

}
Run Code Online (Sandbox Code Playgroud)

错误 -

Exception in thread "main" java.lang.StackOverflowError
    at java.lang.String.length(Unknown Source)
    at java.lang.AbstractStringBuilder.append(Unknown Source)
    at java.lang.StringBuilder.append(Unknown Source)
    at java.lang.StringBuilder.<init>(Unknown Source)
    at com.examscam.model.Tester.toString(Tester.java:13)
    at java.lang.String.valueOf(Unknown Source)
    at java.lang.StringBuilder.append(Unknown Source) …
Run Code Online (Sandbox Code Playgroud)

java stack-overflow

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

使用Microsoft.ACE.OLEDB.12.0将Excel导入SQL Server

尝试在SQL Server 2008 r2 64位中打开Excel文件时出现以下错误:

Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" 
reported an error. The provider did not give any information about the error.
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider 
"Microsoft.ACE.OLEDB.12.0" for linked server "(null)".
Run Code Online (Sandbox Code Playgroud)

我正在使用以下查询:

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0; 
HDR=NO; IMEX=1; Database=\\filepath\filename.xlsx', 'SELECT * FROM [Sheet1$]')
Run Code Online (Sandbox Code Playgroud)

有趣的是,DBA可以毫无问题地运行它.我已经完成并运行了以下查询:

sp_configure 'Show Advanced Options', 1;
RECONFIGURE;
GO …
Run Code Online (Sandbox Code Playgroud)

sql-server excel sql-server-2008

5
推荐指数
2
解决办法
6万
查看次数

是否有任何工具可供arangoDB使用

就像有适用于MySQL的Workbench,用于MS SQL的SQL Management studio,是否有适用于arangoDB的工具?

我搜索了很多但没找到解决办法.

非常感谢您的帮助.先感谢您.

arangodb

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