小编gre*_*ole的帖子

在Python中重新排序嵌套列表条目

是否有重新组合嵌套列表的快捷方式

[[a0,b0,c0],[a1,b1,c1],[a2,b2,b2]]
Run Code Online (Sandbox Code Playgroud)

给这样的东西

 [[a0,a1,a2],[b0,b1,b2],[c0,c1,c2]]
Run Code Online (Sandbox Code Playgroud)

python list

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

扩展SocketServer.TCPServer时出现Python“实例无属性”错误

我正在尝试覆盖该类的serve_forever方法SocketServer.TCPServer。但是我收到一个AttributeError: MyServer instance has no attribute '_MyServer__is_shut_down'错误。

__is_shut_down在实现SocketServer.BaseServer类,应该通过被初始化__init__()SocketServer.TCPServer。我想念什么?

import SocketServer

class MyServer(SocketServer.TCPServer):

    def __init__(self, server_address, RequestHandlerClass):
            SocketServer.TCPServer.__init__(self, server_address, 
                                             RequestHandlerClass)

    def serve_forever(self, poll_interval=0.5):
        self.__is_shut_down.clear()
        try:
            while not self.__shutdown_request:
                 print "SOMETHING"
                 r, w, e = _eintr_retry(select.select, [self], [], [],
                                       poll_interval)
                 if self in r:
                   self._handle_request_noblock()
        finally:
            self.__shutdown_request = False
            self.__is_shut_down.set()
Run Code Online (Sandbox Code Playgroud)

python socketserver

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

从csv文件读取Python日期

我实际上是在尝试从python 2.7.8中的csv文件计算SLA.这是我的csv文件的一个例子:

2014-09-24 23:57:43;0000B169;20
2014-09-24 23:58:05;00012223;20
2014-09-24 23:58:49;00012200;20
2014-09-24 23:59:33;0000B0EA;21
2014-09-25 00:00:17;000121FF;21
2014-09-25 00:00:39;00012217;21
2014-09-25 00:01:01;00012176;20
2014-09-25 00:01:23;00012175;20
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我的CSV文件有两天不同,我希望我的程序能够读取它们并每天计算SLA.这是我的计划:

#V1.1 du programme de Calcul du SLA
import csv
import datetime
with open("/home/maxime/Bureau/Dev/Exports/export2.csv", 'rb') as f:            #import the required modules
    reader = csv.reader(f, delimiter=';')
    count=0              #variable of the date "number"
    for row in reader:
    if row[0] !="Dispatch date":                # we don't want to include the first line of the first column
        date = datetime.datetime.strptime (row [0],"%Y-%m-%d %H:%M:%S")             #creating the datetime object …
Run Code Online (Sandbox Code Playgroud)

python csv format datetime

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

ajax成功后如何刷新表体

$.ajax({
            type:"POST",
            url:"abc.php",
            data:dataString,
            success:function(response){ 

            //alert(response);
            // Here I want to write code to refresh table body          
            }
    });
Run Code Online (Sandbox Code Playgroud)

ajax

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

标签 统计

python ×3

ajax ×1

csv ×1

datetime ×1

format ×1

list ×1

socketserver ×1