社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

aminrd

aminrd 最近创建的主题
aminrd 最近回复了
5 年前
回复了 aminrd 创建的主题 » Python 2.7 server.socket超时问题

你可以用 socket.settimeout(value) 哪里 value 是秒数。

    serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    serversocket.bind(('', port))
    serversocket.listen(5) # become a server socket, maximum 5 connections

    while 1:
        try:
            while 1:
               # print "Waiting for oonnection..."
                connection, address = serversocket.accept()
                connection.settimeout(5) # Set 5 seconds timeout to receive 64 bytes of data

                buf = connection.recv(64)

        except socket.timeout:
            print("Timeout happened -- goting back to accept another connection")
5 年前
回复了 aminrd 创建的主题 » Python将字符串列表转换为整数列表

这应该管用

import re

lists=['111,222','121,121']
results = [ int("".join(re.findall('[0-9]+', element))) for element in lists ] 

# results = [111222, 121121]
5 年前
回复了 aminrd 创建的主题 » 如何在django 2模板中增加值

django模板中有一个内置过滤器,名为 add 是的。您可以使用 {{ value|add:"2" }} 是的。

在这种情况下,请尝试:

<td id="demo">{{ i }} to {{ i|add:"1" }}</td>