Tag: 连接

我怎样才能得到在Python中的两个列表的连接而不修改任何一个?

在Python中,我可以find连接两个列表的唯一方法是list.extend ,它修改第一个列表。 有没有任何连接函数返回其结果而不修改其参数?

Concat SQL中的所有列值

如何将来自sql查询返回的不同行的所有列值连接成一个值? 这是一个例子: 一个查询返回: FOO —— RES1 RES2 RES3 现在我想要得到如下结果: FOOCONCAT —– RES1RES2RES3 有没有办法在SQL中做到这一点?

互联网连接状态变化的Android事件

我正在制作一个应用程序,用户上传信息和文件到我的服务器有点频繁。 这是通过专门的上传服务在新线程中完成的。 我从这个线索知道 检测Android上是否有可用的Internet连接 您可以比较容易地检查是否有互联网连接。 您还可以获取socketTimeoutExceptions来检测Internet连接问题。 所有这一切都很好,并且可以在连接因任何原因而无法工作时轻松地caching我的上传内容。 我的问题是,我怎么知道什么时候重新尝试上传? 连接恢复时是否触发事件? 还是我坚持做一个睡眠的新线程,然后每隔30秒检查一次互联网连接? 任何想法将不胜感激! Avtar

在C中连接string,哪种方法更有效率?

我碰到这两个方法来连接string: 共同部分: char* first= "First"; char* second = "Second"; char* both = malloc(strlen(first) + strlen(second) + 2); 方法1: strcpy(both, first); strcat(both, " "); strcat(both, second); 方法2: sprintf("%s %s", first, second); 在这两种情况下,两者的内容将是"First Second" 。 我想知道哪一个更高效(我必须执行几个级联操作),或者如果你知道更好的方法来做到这一点。 谢谢你的时间。 编辑:在第一种情况下,空间可能已经在一个string内。

RMI连接在本地主机上被拒绝

我正在学习RMI编码,当我运行RMI的服务器端时,我的连接被拒绝。 这是我的服务器主要方法 public static void main(String[] args)throws Exception { Implementation impl=new Implementation(); Naming.rebind("//localhost:2020/RMI", impl); System.out.println("Implementation has been bind to the name RMI and is ready for use"); } 我相信,实现的代码并不重要,因为它只是实现的接口,将运行的代码。 我得到的例外是这个 Exception in thread "main" java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection refused: connect at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source) at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source) at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown […]

无法连接“str”和“float”对象?

我们的几何老师给了我们一个任务,要求我们创造一个玩具在现实生活中使用几何的例子,所以我认为做一个程序来计算需要多less加仑的水才能填满一定数量的池形状和一定的尺寸。 这是迄今为止的计划: import easygui easygui.msgbox("This program will help determine how many gallons will be needed to fill up a pool based off of the dimensions given.") pool=easygui.buttonbox("What is the shape of the pool?", choices=['square/rectangle','circle']) if pool=='circle': height=easygui.enterbox("How deep is the pool?") radius=easygui.enterbox("What is the distance between the edge of the pool and the center of […]

使用NSURLSession下载JSON不会返回任何数据

我目前正在尝试从URL下载,parsing和打印JSON。 到目前为止,我已经到了这个地步: 1)处理我的导入的类(JSONImport.swift): var data = NSMutableData(); let url = NSURL(string:"http://headers.jsontest.com"); var session = NSURLSession.sharedSession(); var jsonError:NSError?; var response : NSURLResponse?; func startConnection(){ let task:NSURLSessionDataTask = session.dataTaskWithURL(url!, completionHandler:apiHandler) task.resume(); self.apiHandler(data,response: response,error: jsonError); } func apiHandler(data:NSData?, response:NSURLResponse?, error:NSError?) { do{ let jsonData : NSDictionary = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as! NSDictionary; print(jsonData); } catch{ print("API error: […]

java.sql.SQLException:找不到适合jdbc的驱动程序:mysql:// localhost:3306 / dbname

我有这个Java程序: MySQLConnectExample.java import java.sql.*; import java.util.Properties; public class MySQLConnectExample { public static void main(String[] args) { Connection conn1 = null; Connection conn2 = null; Connection conn3 = null; try { String url1 = "jdbc:mysql://localhost:3306/aavikme"; String user = "root"; String password = "aa"; conn1 = DriverManager.getConnection(url1, user, password); if (conn1 != null) System.out.println("Connected to the database […]

如何立即closuresNode.js http服务器?

我有一个包含http(s)服务器的Node.js应用程序。 在特定情况下,我需要以编程方式closures此服务器。 我现在正在调用它的close()函数,但是这并没有帮助,因为它等待任何保持活动的连接首先完成。 所以,基本上,这closures了服务器,但只有最less120秒的等待时间。 但是我希望服务器立即closures – 即使这意味着与当前处理的请求分离。 我不能做的是一个简单的 process.exit(); 因为服务器只是应用程序的一部分,应用程序的其余部分应该保持运行。 我正在寻找的是概念上的东西,如server.destroy(); 或类似的东西。 我怎么能做到这一点? PS:连接的保持活动超时通常是必需的,因此减less这个时间不是一个可行的select。

Python 地址已经在使用中

在我的Python套接字程序中,我有时需要用Ctrl-C来中断它。 当我这样做时,它会使用socket.close()closures连接。 但是,当我尝试重新打开它时,我必须等待一下,然后才能再次连接。 如何正确closures套接字? 或者这是打算?