小编use*_*771的帖子

Pyqt Gui在循环中冻结

我用PyQt制作端口扫描程序,但是当我激活循环时,Gui冻结.我怎么能解决这个问题?我添加了time.sleep()函数,但它仍然冻结.这是它冻结的功能.谢谢.

        try:
            time.sleep(1) 
            hostname=self.adres.text()
            hostip=socket.gethostbyname(hostname)
            uyari1="Scanning remote host, {}\n".format(hostip)
            self.durum.append(uyari1)
            print(uyari1)
            for port in range(1,1025):
                time.sleep(0.1)  
                sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                result = sock.connect_ex((hostip, port))
                if result == 0:
                    time.sleep(0.01) 
                    print ("Port {}: \t Open".format(port))
                    self.durum.append("Port {}: \t Open\n".format(port))
                sock.close()
Run Code Online (Sandbox Code Playgroud)

完整代码:

import socket,os,time
from PyQt4 import QtCore, QtGui

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s

try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig) …
Run Code Online (Sandbox Code Playgroud)

python pyqt pyqt4

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

C++ if-else if Issues

我在下面的程序中遇到问题.它应该将1-100之间的数字转换为AA,BA,BB,CB,CC,D,F.但是如果我输入的数字少于84,它就会停止工作并显示"BA".我检查了代码.但我不明白这是什么问题.

#include <iostream>
using namespace std;

int main() {
    int secenek,notu;
    cout << "Not Dönü?türücü" << endl;
    cout<<"Ba?lamak için 1'e bas?n:\n";
    cin>>secenek;

    if (secenek==1)
        {
        cout<<"Dönü?türülecek not: ";
        cin>>notu;
        }
        if (notu<0 || notu>100)
            {
            cout<<"Geçerli bir not girin.\n";
            }
        else if (notu>=90)
            {
            cout<<"AA";
            }
        else if (notu<90 || notu>84)
            {
            cout<<"BA";
            }
        else if (notu<85 || notu>79)
            {
            cout<<"BB";
            }
        else if (notu<80 || notu>74)
            {
            cout<<"CB";
            }
        else if (notu<75 || notu>69)
            {
            cout<<"CC";
            }
        else if …
Run Code Online (Sandbox Code Playgroud)

c++ if-statement

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

标签 统计

c++ ×1

if-statement ×1

pyqt ×1

pyqt4 ×1

python ×1