小编ali*_*eza的帖子

我可以在Django(dev 1.6.x)上使用Python和Python3.x吗?

我使用混帐回购协议的Django开发(1.6.x版),我想使用MySQL,但在settings.py文件无法安装的MySQL因为MySQL不python3和Django的支持,所以我用pymysql包上python3.x没有任何问题,但在Django中也无法设置它settings.py.

我可以使用与python3 Django的MySQL的(或pymysql或?)?

python django python-3.x

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

OSError:[Errno 22] python3套接字中的参数无效

我在Python 3中遇到套接字编程问题.我得到一个异常,它不会导致程序崩溃,但只是在终端中显示.

这是我的代码:

from PyQt4 import QtCore, QtGui
from imigui import Ui_MainWindow

class imiserv(QtGui.QMainWindow):

    send_msg = pyqtSignal('QString', 'QString')

    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.Sport_lineEdit.setMaxLength(5)
        self.ui.Sconnect_pushButton.clicked.connect(self.serv)

        self.send_msg.connect(self.write_msg)

    def write_msg(self, lbl_msg= None, txt_msg= None):
        if lbl_msg:
            self.ui.C_label.setText(lbl_msg)
        if txt_msg:
            self.ui.Clog_textEdit.setText(txt_msg)

    def serv(self):
        MY_LOCK = threading.Lock()
        class CountT(threading.Thread):
            def __init__(self, parent):
                threading.Thread.__init__(self)
                self._parent= parent

            def run(self):
                MY_LOCK.acquire()
                self._parent.send_msg.emit("Waiting connections","")
                while True:
                    cliconn, (addr, remoport)= self._parent.clis.accept()
                    clirecmsg= str(cliconn.recv(1024)
                    self._parent.send_msg.emit("{0}:{1} is connected.".format(addr, remoport), "{0}:{1}".format(addr, remoport)
                    cliconn.close()

                MY_LOCK.release()

        try:
            self.clis= socket.socket(socket.AF_INET, socket.SOCK_STREAM) …
Run Code Online (Sandbox Code Playgroud)

python sockets pyqt4 python-3.x

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

如何在linux中使用cx_freeze来创建一个在windows中使用的包

如何在linux中使用cx_freeze来创建一个在.exe或.bin文件等窗口中使用的包.我在linux中测试了cx_freeze,但是在linux和windows中制作包是未知的.

例如 :

$ cxfreeze gui.py
Run Code Online (Sandbox Code Playgroud)

这是制作的文件:

gui
Run Code Online (Sandbox Code Playgroud)

那只在linux中运行.

有没有办法使用cx_freeze来制作exe或bin包?

或者使用任何替代方法而不是cx_freeze来使一个bin文件在其他平台中独立执行?

我使用python3(3.x).

linux cx-freeze python-3.x

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

处理用户在电报机器人中删除的消息

有什么方法可以在一对一聊天或机器人所属的群组中处理用户删除的消息?有编辑消息更新的方法,但没有删除消息的方法。

python-telegram-bot telegram-bot

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

来自外部的sendMessage在autobahn中运行在单独的线程中

我想sendMessageMyServerProtocol类外部调用方法并向连接的客户端发送消息.我习惯threading这样做.

当我使用这段代码时:

from autobahn.twisted.websocket import WebSocketServerProtocol, WebSocketServerFactory
from twisted.internet import reactor
import threading

class MyServerProtocol(WebSocketServerProtocol):
    def onConnect(self, request):
        print("Client connecting: {0}".format(request.peer))

    def onOpen(self):
        print("WebSocket connection open.")

    def onMessage(self, payload, isBinary):
        if isBinary:
            print("Binary message received: {0} bytes".format(len(payload)))
        else:
            print("Text message received: {0}".format(payload.decode('utf8')))

        self.sendMessage(payload, isBinary)

    def onClose(self, wasClean, code, reason):
        print("WebSocket connection closed: {0}".format(reason))


class Connection(threading.Thread):
    def __init__(self):
        super(Connection, self).__init__()

    def run(self):
        self.factory = WebSocketServerFactory("ws://localhost:9000", debug=False)
        self.factory.protocol = MyServerProtocol
        reactor.listenTCP(9000, self.factory)
        reactor.run(installSignalHandlers=0)

    def send(self, data): …
Run Code Online (Sandbox Code Playgroud)

python autobahn

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