报错:sys.argv[1] IndexError: list index out of range?

运行时报错:firstFolder = sys.argv[1]
IndexError: list index out of range
怎么回事?

import numpy as np
import cv2
import sys
from matplotlib import pyplot as plt

# img = cv2.imread('logo.png',0)
# # Initiate ORB detector
# orb = cv2.ORB_create()
# # find the keypoints with ORB
# kp = orb.detect(img,None)
# # compute the descriptors with ORB
# kp, des = orb.compute(img, kp)
# # draw only keypoints location,not size and orientation
# img2 = cv2.drawKeypoints(img, kp, None, color=(0,255,0), flags=0)
# plt.imshow(img2), plt.show()

from os import listdir
from os.path import isfile, join


class Application:
    def __init__(self, extractor, detector):
        self.extractor = extractor
        self.detector = detector

    def train_vocabulary(self, file_list, vocabulary_size):
        kmeans_trainer = cv2.BOWKMeansTrainer(vocabulary_size)
        for path_to_image in file_list:
            img = cv2.imread(path_to_image, 0)
            kp, des = self.detector.detectAndCompute(img, None)
            kmeans_trainer.add(des)
        return kmeans_trainer.cluster()

    def extract_features_from_image(self, file_name):
        image = cv2.imread(file_name)
        return self.extractor.compute(image, self.detector.detect(image))

    def extract_train_data(self, file_list, category):
        train_data, train_responses = [], []
        for path_to_file in file_list:
            train_data.extend(self.extract_features_from_image(path_to_file))
            train_responses.append(category)
        return train_data, train_responses

    def train_classifier(self, data, responses):
        n_trees = 200
        max_depth = 10
        model = cv2.ml.RTrees_create()
        eps = 1
        criteria = (cv2.TERM_CRITERIA_MAX_ITER, n_trees, eps)
        model.setTermCriteria(criteria)
        model.setMaxDepth(max_depth)
        model.train(np.array(data), cv2.ml.ROW_SAMPLE, np.array(responses))
        return model

    def predict(self, file_name):
        features = self.extract_features_from_image(file_name)
        return self.classifier.predict(features)[0]

    def train(self, files_array, vocabulary_size=12):
        all_categories = []
        for category in files_array:
            all_categories += category

        vocabulary = self.train_vocabulary(all_categories, vocabulary_size)
        self.extractor.setVocabulary(vocabulary)

        data = []
        responses = []
        for id in range(len(files_array)):
            data_temp, responses_temp = self.extract_train_data(files_array[id], id)
            data += data_temp
            responses += responses_temp

        self.classifier = self.train_classifier(data, responses)

    def error(self, file_list, category):
        responses = np.array([self.predict(file) for file in file_list])
        _responses = np.array([category for _ in range(len(responses))])
        return 1 - np.sum(responses == _responses) / len(responses)


def get_images_from_folder(folder):
    return ["%s/%s" % (folder, f) for f in listdir(folder) if isfile(join(folder, f))]


def start(folders, detector_type, voc_size, train_proportion):
    if detector_type == "SIFT":
        # "Scale Invariant Feature Transform"
        extract = cv2.xfeatures2d.SIFT_create()
        detector = cv2.xfeatures2d.SIFT_create()
    else:
        # "Speeded up Robust Features"
        extract = cv2.xfeatures2d.SURF_create()
        detector = cv2.xfeatures2d.SURF_create()
    flann_params = dict(algorithm=1, trees=5)
    matcher = cv2.FlannBasedMatcher(flann_params, {})
    extractor = cv2.BOWImgDescriptorExtractor(extract, matcher)

    train = []
    test = []
    for folder in folders:
        images = get_images_from_folder(folder)
        np.random.shuffle(images)

        slice = int(len(images) * train_proportion)
        train_images = images[0:slice]
        test_images = images[slice:]
        train.append(train_images)
        test.append(test_images)

    app = Application(extractor, detector)
    app.train(train, voc_size)

    total_error = 0.0

    for id in range(len(test)):
        print(app.error(train[id], id))
        test_error = app.error(test[id], id)
        print(test_error)
        print("---------")
        total_error = total_error + test_error

    total_error = total_error / float(len(test))
    print("Total error = %f" % total_error)


firstFolder = sys.argv[1]
secondFolder = sys.argv[2]
detectorType = sys.argv[3]
vocSize = int(sys.argv[4])
trainProportion = float(sys.argv[5])

start([firstFolder, secondFolder], detectorType, vocSize, trainProportion)


1个回答

你运行的时候有没有带上参数,并且这个参数应该是你的文件夹的路径

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Python中 sys.argv[0] = re.sub这句话什么意思?
if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.exit(main()) Python中 sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])这句话什么意思? 那我懂Python和正则的帮我解析一下,非常感谢
关于pyside2在pycharm中运行出错 app = QApplication(sys.argv) TypeError: 'NoneType' object is not callable?
在pycharm中运行这段报错: ``` import sys from PySide2.QtWidgets import QApplication, QLabel print(sys.argv) app = QApplication.instance() if app == None: app = QApplication(sys.argv) # QLabel组件用于显示文本 label = QLabel("<font color=red size=40>Hello World!</font>") label.show() app.exec_() ``` ``` Traceback (most recent call last): File "E:/工作/copy2/Test.py", line 7, in <module> app = QApplication(sys.argv) TypeError: 'NoneType' object is not callable ``` 但是在python编译器里面就不会报错,求指点?
python中sys.argv的用法
if len(sys.argv)!=2 or sys.argv[1] not in shared.valid_width_classes: print("Usage: ", sys.argv[0], " <width_class>") sys.exit(-1) valid_width_classes 是在另一个py文件, valid_width_classes = ['identity','largest_first','largest_last'] 程序运行的时候没有让输入命令,直接显示路径就退出了,这是什么原因,有没有大神解惑一下!
python中sys.argv[1:]到底是什么意思呢?
1 import sys 2 import Image 3 4 for infile in sys.argv[1:]: 5 try: 6 im = Image.open(infile) 7 print infile, im.format, "%dx%d" % im.size, im.mode 8 except IOError: 9 pass 大神们,请问for infile in sys.argv[1:]到底是什么意思呢?新手,请解答简单明了一些,您的回答能帮助我解决燃眉之急!!在此非常之感谢!
sys.argv[1]报错;命令行参数
![图片说明](https://img-ask.csdn.net/upload/201910/01/1569943881_464034.png) sys.argv[1]报错,显示超出列表范围 然后查了下资料,了解了argv的一些基本用法,在这里需要传入其他的参数 这个具体应该传什么参数,是怎么确定的,麻烦路过的大神指点一下
N = int(sys.argv[1])报错
我是在Eclipse下编写的python程序,每次用N = int(sys.argv[1])都会报错,求各位大神帮忙指导一下,万分感谢![图片说明](https://img-ask.csdn.net/upload/201612/11/1481466983_525149.png)
IndexError: list index out of range
#coding:utf-8 -*- #! /user/bin/env/python # python vectorsum.py 1000 import sys import numpy as np from datetime import datetime """input format�� python vectorsum.py n n: the expected size for the vector""" def pythonSum(n): a = range(n) b = range(n) c = [] for i in range(n): a[i] = i ** 2 b[i] = i ** 3 c.append(a[i]+b[i]) return c def numpysum(n): a = np.arange(n) ** 2 b = np.arange(n) ** 3 c = a + b return c size = int(sys.argv[1]) start = datetime.now() c = pythonSum(size) delta = datetime.now() - start print ("The last 2 elements of the sum", c[-2:]) print ("pythonSum elspaed time in microseconds", delta.microseconds) start = datetime.now() c = numpysum(size) delta = datetime.now() - start print ("The last 2 elements of the sum", c[-2:]) print ("numpysum elspaed time in microseconds", delta.microseconds) 运行结果:Traceback (most recent call last): File "D:\workspace\PythonLearn1\src\NumpyLearn\__init__.py", line 26, in <module> size = int(sys.argv[1]) IndexError: list index out of range 我用的是Eclipse下的 python,请问这个越界了,应该在哪里输入 python vectorsum.py n,各位大神,帮忙解决一下吧
python可变参数传递给方法问题
import sys def foo(a, b=None, c=None): print(b,c) foo(sys.argv[1],sys.argv[2],sys.argv[3]) 脚本从sys.argv获得参数,必须上面写才能获得b,c的值 执行 python 51.py 1 2 3 像foo(sys.argv[1:]) 所有变量作为列表传给a,b,c仍为空。 请指点该如何处理?
ImportError: QtWebEngineWidgets must be imported before a QCoreApplication instance is created如何解决?
在学习PyQt5+pyecharts 实现GUI界面的数据可视化展示过程中,遇到了QtWebEngineWidgets导入的问题,尝试过网上的各种办法,均没有解决,求高手指导,下面是代码及相关报错 ``` #from PyQt5.QtWebChannel import QWebChannel from PyQt5.QtCore import QUrl from PyQt5.QtWidgets import QApplication,QWidget,QHBoxLayout,QFrame from PyQt5.QtWebEngineWidgets import QWebEngineView import sys class Stacked(QWidget): def __init__(self): super(Stacked, self).__init__() self.initUI() self.mainLayout() def initUI(self): self.setGeometry(400,400,800,600) self.setWindowTitle("demo1") def mainLayout(self): self.mainhboxLayout = QHBoxLayout(self) self.frame = QFrame(self) self.mainhboxLayout.addWidget(self.frame) self.hboxLayout = QHBoxLayout(self.frame) self.myHtml = QWebEngineView() url = "http://www.baidu.com" #打开本地html文件 self.myHtml.load(QUrl("file:///D:/360Downloads/Python编程/数据分析+数据可视化/pyecharts/PyQt5+pyecharts/bar1.html")) # self.myHtml.load(QUrl("bar1.html")) #无法显示,要使用绝对地址定位,在地址前面加上 file:/// ,将地址的 \ 改为/ #打开网页url # self.myHtml.load(QUrl(url)) self.hboxLayout.addWidget(self.myHtml) self.setLayout(self.mainhboxLayout) if __name__ == '__main__': app = QApplication(sys.argv) ex = Stacked() ex.show() sys.exit(app.exec_()) ``` 报错: QtWebEngineWidgets must be imported before a QCoreApplication instance is created
PyQt5 import出现问题求解
代码: import sys from PyQt5.QtWidgets import QApplication, QLabel if __name__ == '__main__': app = QApplication(sys.argv) # 1 label = QLabel('1') # 2 label.show() # 3 sys.exit(app.exec_()) # 4 提示: ModuleNotFoundError: No module named 'PyQt5.Qt'; 'PyQt5' is not a package
python+opencv+pyqt5 车牌批量识别报错
**单个儿车牌识别,代码运行成功,代码如下:** ``` from PyQt5 import QtCore,QtGui, QtWidgets from PyQt5.QtGui import * from PyQt5.QtCore import Qt from PyQt5.QtWidgets import * from Recognition import PlateRecognition import cv2 import sys, os, xlwt import numpy as np class Ui_MainWindow(object): def __init__(self): self.RowLength = 0 self.Data = [['文件名称', '录入时间', '车牌号码', '车牌类型', '识别耗时', '车牌信息']] def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(1213, 670) MainWindow.setFixedSize(1213, 670) # 设置窗体固定大小 MainWindow.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.scrollArea = QtWidgets.QScrollArea(self.centralwidget) self.scrollArea.setGeometry(QtCore.QRect(690, 10, 511, 491)) self.scrollArea.setWidgetResizable(True) self.scrollArea.setObjectName("scrollArea") self.scrollAreaWidgetContents = QtWidgets.QWidget() self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 509, 489)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.label_0 = QtWidgets.QLabel(self.scrollAreaWidgetContents) self.label_0.setGeometry(QtCore.QRect(10, 10, 111, 20)) font = QtGui.QFont() font.setPointSize(11) self.label_0.setFont(font) self.label_0.setObjectName("label_0") self.label = QtWidgets.QLabel(self.scrollAreaWidgetContents) self.label.setGeometry(QtCore.QRect(10, 40, 481, 441)) self.label.setObjectName("label") self.label.setAlignment(Qt.AlignCenter) self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.scrollArea_2 = QtWidgets.QScrollArea(self.centralwidget) self.scrollArea_2.setGeometry(QtCore.QRect(10, 10, 671, 631)) self.scrollArea_2.setWidgetResizable(True) self.scrollArea_2.setObjectName("scrollArea_2") self.scrollAreaWidgetContents_1 = QtWidgets.QWidget() self.scrollAreaWidgetContents_1.setGeometry(QtCore.QRect(0, 0, 669, 629)) self.scrollAreaWidgetContents_1.setObjectName("scrollAreaWidgetContents_1") self.label_1 = QtWidgets.QLabel(self.scrollAreaWidgetContents_1) self.label_1.setGeometry(QtCore.QRect(10, 10, 111, 20)) font = QtGui.QFont() font.setPointSize(11) self.label_1.setFont(font) self.label_1.setObjectName("label_1") self.tableWidget = QtWidgets.QTableWidget(self.scrollAreaWidgetContents_1) self.tableWidget.setGeometry(QtCore.QRect(10, 40, 651, 581)) # 581)) self.tableWidget.setObjectName("tableWidget") self.tableWidget.setColumnCount(6) self.tableWidget.setColumnWidth(0, 140) # 设置1列的宽度 self.tableWidget.setColumnWidth(1, 130) # 设置2列的宽度 self.tableWidget.setColumnWidth(2, 65) # 设置3列的宽度 self.tableWidget.setColumnWidth(3, 75) # 设置4列的宽度 self.tableWidget.setColumnWidth(4, 65) # 设置5列的宽度 self.tableWidget.setColumnWidth(5, 174) # 设置6列的宽度 self.tableWidget.setHorizontalHeaderLabels(["图片名称", "录入时间", "识别耗时", "车牌号码", "车牌类型", "车牌信息"]) self.tableWidget.setRowCount(self.RowLength) self.tableWidget.verticalHeader().setVisible(False) # 隐藏垂直表头) # self.tableWidget.setStyleSheet("selection-background-color:blue") # self.tableWidget.setAlternatingRowColors(True) self.tableWidget.setEditTriggers(QAbstractItemView.NoEditTriggers) self.tableWidget.raise_() self.scrollArea_2.setWidget(self.scrollAreaWidgetContents_1) self.scrollArea_3 = QtWidgets.QScrollArea(self.centralwidget) self.scrollArea_3.setGeometry(QtCore.QRect(690, 510, 341, 131)) self.scrollArea_3.setWidgetResizable(True) self.scrollArea_3.setObjectName("scrollArea_3") self.scrollAreaWidgetContents_3 = QtWidgets.QWidget() self.scrollAreaWidgetContents_3.setGeometry(QtCore.QRect(0, 0, 339, 129)) self.scrollAreaWidgetContents_3.setObjectName("scrollAreaWidgetContents_3") self.label_2 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) self.label_2.setGeometry(QtCore.QRect(10, 10, 111, 20)) font = QtGui.QFont() font.setPointSize(11) self.label_2.setFont(font) self.label_2.setObjectName("label_2") self.label_3 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) self.label_3.setGeometry(QtCore.QRect(10, 40, 321, 81)) self.label_3.setObjectName("label_3") self.scrollArea_3.setWidget(self.scrollAreaWidgetContents_3) self.scrollArea_4 = QtWidgets.QScrollArea(self.centralwidget) self.scrollArea_4.setGeometry(QtCore.QRect(1040, 510, 161, 131)) self.scrollArea_4.setWidgetResizable(True) self.scrollArea_4.setObjectName("scrollArea_4") self.scrollAreaWidgetContents_4 = QtWidgets.QWidget() self.scrollAreaWidgetContents_4.setGeometry(QtCore.QRect(0, 0, 159, 129)) self.scrollAreaWidgetContents_4.setObjectName("scrollAreaWidgetContents_4") self.pushButton_2 = QtWidgets.QPushButton(self.scrollAreaWidgetContents_4) self.pushButton_2.setGeometry(QtCore.QRect(20, 50, 121, 31)) self.pushButton_2.setObjectName("pushButton_2") self.pushButton = QtWidgets.QPushButton(self.scrollAreaWidgetContents_4) self.pushButton.setGeometry(QtCore.QRect(20, 90, 121, 31)) self.pushButton.setObjectName("pushButton") self.label_4 = QtWidgets.QLabel(self.scrollAreaWidgetContents_4) self.label_4.setGeometry(QtCore.QRect(10, 10, 111, 20)) font = QtGui.QFont() font.setPointSize(11) self.label_4.setFont(font) self.label_4.setObjectName("label_4") self.scrollArea_4.setWidget(self.scrollAreaWidgetContents_4) MainWindow.setCentralWidget(self.centralwidget) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) self.pushButton.clicked.connect(self.__openimage) # 设置点击事件 self.pushButton_2.clicked.connect(self.__writeFiles) # 设置点击事件 self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) self.ProjectPath = os.getcwd() # 获取当前工程文件位置 def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "车牌识别系统")) self.label_0.setText(_translate("MainWindow", "原始图片:")) self.label.setText(_translate("MainWindow", "")) self.label_1.setText(_translate("MainWindow", "识别结果:")) self.label_2.setText(_translate("MainWindow", "车牌区域:")) self.label_3.setText(_translate("MainWindow", "")) self.pushButton.setText(_translate("MainWindow", "打开文件")) self.pushButton_2.setText(_translate("MainWindow", "导出数据")) self.label_4.setText(_translate("MainWindow", "命令:")) self.scrollAreaWidgetContents_1.show() # 识别 def __vlpr(self, path): PR = PlateRecognition() result = PR.VLPR(path) return result def __show(self, result, FileName): # 显示表格 self.RowLength = self.RowLength + 1 if self.RowLength > 18: self.tableWidget.setColumnWidth(5, 157) self.tableWidget.setRowCount(self.RowLength) self.tableWidget.setItem(self.RowLength - 1, 0, QTableWidgetItem(FileName)) self.tableWidget.setItem(self.RowLength - 1, 1, QTableWidgetItem(result['InputTime'])) self.tableWidget.setItem(self.RowLength - 1, 2, QTableWidgetItem(str(result['UseTime']) + '秒')) self.tableWidget.setItem(self.RowLength - 1, 3, QTableWidgetItem(result['Number'])) self.tableWidget.setItem(self.RowLength - 1, 4, QTableWidgetItem(result['Type'])) if result['Type'] == '蓝色牌照': self.tableWidget.item(self.RowLength - 1, 4).setBackground(QBrush(QColor(3, 128, 255))) elif result['Type'] == '绿色牌照': self.tableWidget.item(self.RowLength - 1, 4).setBackground(QBrush(QColor(98, 198, 148))) elif result['Type'] == '黄色牌照': self.tableWidget.item(self.RowLength - 1, 4).setBackground(QBrush(QColor(242, 202, 9))) self.tableWidget.setItem(self.RowLength - 1, 5, QTableWidgetItem(result['From'])) # 显示识别到的车牌位置 size = (int(self.label_3.width()), int(self.label_3.height())) shrink = cv2.resize(result['Picture'], size, interpolation=cv2.INTER_AREA) shrink = cv2.cvtColor(shrink, cv2.COLOR_BGR2RGB) self.QtImg = QtGui.QImage(shrink[:], shrink.shape[1], shrink.shape[0], shrink.shape[1] * 3, QtGui.QImage.Format_RGB888) self.label_3.setPixmap(QtGui.QPixmap.fromImage(self.QtImg)) def __writexls(self, DATA, path): wb = xlwt.Workbook(); ws = wb.add_sheet('Data'); # DATA.insert(0, ['文件名称','录入时间', '车牌号码', '车牌类型', '识别耗时', '车牌信息']) for i, Data in enumerate(DATA): for j, data in enumerate(Data): ws.write(i, j, data) wb.save(path) QMessageBox.information(None, "成功", "数据已保存!", QMessageBox.Yes) def __writecsv(self, DATA, path): f = open(path, 'w') # DATA.insert(0, ['文件名称','录入时间', '车牌号码', '车牌类型', '识别耗时', '车牌信息']) for data in DATA: f.write((',').join(data) + '\n') f.close() QMessageBox.information(None, "成功", "数据已保存!", QMessageBox.Yes) def __writeFiles(self): path, filetype = QFileDialog.getSaveFileName(None, "另存为", self.ProjectPath, "Excel 工作簿(*.xls);;CSV (逗号分隔)(*.csv)") if path == "": # 未选择 return if filetype == 'Excel 工作簿(*.xls)': self.__writexls(self.Data, path) elif filetype == 'CSV (逗号分隔)(*.csv)': self.__writecsv(self.Data, path) def __openimage(self): path, filetype = QFileDialog.getOpenFileName(None, "选择文件", self.ProjectPath, "JPEG Image (*.jpg);;PNG Image (*.png);;JFIF Image (*.jfif)") # ;;All Files (*) if path == "": # 未选择文件 return filename = path.split('/')[-1] # 尺寸适配 size = cv2.imdecode(np.fromfile(path, dtype=np.uint8), cv2.IMREAD_COLOR).shape if size[0] / size[1] > 1.0907: w = size[1] * self.label.height() / size[0] h = self.label.height() jpg = QtGui.QPixmap(path).scaled(w, h) elif size[0] / size[1] < 1.0907: w = self.label.width() h = size[0] * self.label.width() / size[1] jpg = QtGui.QPixmap(path).scaled(w, h) else: jpg = QtGui.QPixmap(path).scaled(self.label.width(), self.label.height()) self.label.setPixmap(jpg) result = self.__vlpr(path) if result is not None: self.Data.append( [filename, result['InputTime'], result['Number'], result['Type'], str(result['UseTime']) + '秒', result['From']]) self.__show(result, filename) else: QMessageBox.warning(None, "Error", "无法识别此图像!", QMessageBox.Yes) # 重写MainWindow类 class MainWindow(QtWidgets.QMainWindow): def closeEvent(self, event): reply = QtWidgets.QMessageBox.question(self, '提示', "是否要退出程序?\n提示:退出后将丢失所有识别数据", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.No) if reply == QtWidgets.QMessageBox.Yes: event.accept() else: event.ignore() if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) MainWindow = MainWindow() ui = Ui_MainWindow() ui.setupUi(MainWindow) MainWindow.show() sys.exit(app.exec_()) ``` **然后我在单个识别的基础上,增加了几行代码改成批量识别,红色框的是新添加的,其余代码没有改变** ![图片说明](https://img-ask.csdn.net/upload/202003/19/1584629478_989190.png) ![图片说明](https://img-ask.csdn.net/upload/202003/19/1584629493_573295.png) **程序报错:Process finished with exit code -1073740791 (0xC0000409)** ![图片说明](https://img-ask.csdn.net/upload/202003/19/1584629516_819110.png) 大佬们帮帮小白吧,这个增加批量识别的代码是否正确,这个错怎么改。感激不尽!
pyqt5这个为什么所有按钮都输出的是b4?不用列表的时候好像不会出现这种情况,这是怎么回事?要怎么解决?
class MyWidget(QWidget): def __init__(self): super(MyWidget, self).__init__() self.setupUi() self.setupFunction() self.show() def setupUi(self): self.layout = QGridLayout() self.setLayout(self.layout) self.bts = [] for i in range(5): self.bts.append(QPushButton('b'+str(i))) self.layout.addWidget(self.bts[i]) def setupFunction(self): for i in range(5): self.bts[i].clicked.connect(lambda :self.printStr(self.bts[i].text())) def printStr(self, str): print(str) if __name__ == '__main__': app = QApplication(sys.argv) wl = [MyWidget()] sys.exit(app.exec_())
Python利用Gui做简单计算器出现could not convert string to float怎么弄
用UI做出来了一个计算器,按键也都设置好了,什么布局都弄好了,然后再文件夹里新建一个文件,引用UI,想弹出一个计算器来,但点击弹出来的计算器就会could not convert string to float这个错误 代码:# 系统包 import sys from PyQt5 import QtCore, QtGui, QtWidgets # 项目包 from Ui_MainWindow import Ui_MainWindow class CMainWindow(QtWidgets.QMainWindow, Ui_MainWindow): def __init__(self, parent = None): super(CMainWindow, self).__init__(parent) self.setupUi(self) # 主窗体设置 self.setFixedSize(self.width(), self.height()) self.show() def AddNumber(self, number): if number == ".": if self.txtDisplay.text().find(".") == -1: self.txtDisplay.setText(self.txtDisplay.text() + number) else: if self.txtDisplay.text().find(".") == -1: if float(self.txtDisplay.text()) == 0: self.txtDisplay.setText("") self.txtDisplay.setText(self.txtDisplay.text() + number) if float(self.txtDisplay.text()) == 0: self.txtDisplay.setText("0") else: self.txtDisplay.setText(self.txtDisplay.text() + number) def Push00(self): self.AddNumber("00") def Push0(self): self.AddNumber("0") def Push1(self): self.AddNumber("1") def Push2(self): self.AddNumber("2") def Push3(self): self.AddNumber("3") def Push4(self): self.AddNumber("4") def Push5(self): self.AddNumber("5") def Push6(self): self.AddNumber("6") def Push7(self): self.AddNumber("7") def Push8(self): self.AddNumber("8") def Push9(self): self.AddNumber("9") def PushDot(self): self.AddNumber(".") def PushClr(self): self.txtDisplay.setText("0") def PushAdd(self): pass def PushSub(self): pass def PushMul(self): pass def PushDiv(self): pass def PushEqr(self): pass if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) MainWindow = CMainWindow() sys.exit(app.exec_()) ```
AttributeError: module 'keras.backend' has no attribute 'set_image_dim_ordering'
运行后报错,出现以下问题,试过很多方法但就是不行,请问这怎么解决 ![图片说明](https://img-ask.csdn.net/upload/202003/06/1583479858_171879.png) ``` D:\ProgramFiles\Anaconda3\python.exe F:/课程/lpr-master/lpr.py Using TensorFlow backend. 2020-03-06 14:30:11.878437: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found 2020-03-06 14:30:11.916527: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. Traceback (most recent call last): File "F:/课程/lpr-master/lpr.py", line 12, in <module> from hyperlpr_py3 import pipline as pp File "F:\课程\lpr-master\hyperlpr_py3\pipline.py", line 5, in <module> from . import segmentation File "F:\课程\lpr-master\hyperlpr_py3\segmentation.py", line 22, in <module> K.set_image_dim_ordering('tf') AttributeError: module 'keras.backend' has no attribute 'set_image_dim_ordering' Process finished with exit code 1 ``` 看了这位大大的解决方法,我输入命令后(pip install h5py==2.8.0rc1),却疯狂报错 ![图片说明](https://img-ask.csdn.net/upload/202003/06/1583479156_634297.jpg) 错误如下 ``` D:\>pip install h5py==2.8.0rc1 Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting h5py==2.8.0rc1 Using cached https://pypi.tuna.tsinghua.edu.cn/packages/34/07/4f8f6e4e478e9eabde25dea6b4478016e625b2dac6aaded78ba0316c86fe/h5py-2.8.0rc1.tar.gz (263 kB) Requirement already satisfied: numpy>=1.7 in d:\programfiles\anaconda3\lib\site-packages (from h5py==2.8.0rc1) (1.16.5) Requirement already satisfied: six in d:\programfiles\anaconda3\lib\site-packages (from h5py==2.8.0rc1) (1.12.0) Building wheels for collected packages: h5py Building wheel for h5py (setup.py) ... error ERROR: Command errored out with exit status 1: command: 'd:\programfiles\anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\93790\\AppData\\Local\\Temp\\pip-install-5rvq0cey\\h5py\\setup.py'"'"'; __file__='"'"'C:\\Users\\93790\\AppData\\Local\\Temp\\pip-install-5rvq0cey\\h5py\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\93790\AppData\Local\Temp\pip-wheel-f05vtg7o' cwd: C:\Users\93790\AppData\Local\Temp\pip-install-5rvq0cey\h5py\ Complete output (1294 lines):(1294行错误) .......... building 'h5py.defs' extension error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/ ---------------------------------------- Rolling back uninstall of h5py Moving to d:\programfiles\anaconda3\lib\site-packages\h5py-2.9.0.dist-info\ from d:\programfiles\anaconda3\lib\site-packages\~5py-2.9.0.dist-info Moving to d:\programfiles\anaconda3\lib\site-packages\h5py\ from d:\programfiles\anaconda3\lib\site-packages\~5py ERROR: Command errored out with exit status 1: 'd:\programfiles\anaco nda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\93790\\AppData\\Local\\Temp\\pip-install-5rvq0cey\\h5py\\setup.py'"'"'; __file__='"'"'C:\\Users\\93790\\AppData\\Local\\Temp\\pip-install-5rvq0cey\\h5py\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\93790\AppData\Local\Temp\pip-record-zz3q07kh\install-record.txt' --single-version-externally-managed --compile --install-headers 'd:\programfiles\anaconda3\Include\h5py' Check the logs for full command output. ```
python基础教程13章的数据库代码案例不能正常运行
import sqlite3 def convert(value): if value.startswith('~'): return value.strip('~') if not value: value='0' return float(value) conn=sqlite3.connect('food.db') curs=conn.cursor() curs.execute(''' CREATE TABLE food( id TEXT PRIMARY KEY, desc TEXT, water FLOAT, kcal FLOAT, protein FLOAT, fat FLOAT, ash FLOAT, carbs FLOAT, fiber FLOAT, sugar FLOAT ) ''') query='INSERT INTO food VALUES(?,?,?,?,?,?,?,?,?,?)' field_count = 10 for line in open('ABBREV.txt'): fields=line.split('^') vals=[convert(f) for f in fields[:field_count]] curs.execute(query,vals) conn.commit() conn.close() 之后是下面的数据库查询程序 import sqlite3,sys conn = sqlite3.connect('food.db') curs = conn.cursor() query = 'SELECT*FROM food WHERE'+ sys.argv[1] print(query) curs.execute(query) names = [f[0] for f in curs.description] for row in curs.fetchall(): for pair in zip(names,row): print('{}:{}'.format(*pair)) print() 之后显示 Traceback (most recent call last): File "C:/Users/Administrator/AppData/Local/Programs/Python/Python38/123.py", line 6, in <module> query = 'SELECT*FROM food WHERE'+ sys.argv[1] IndexError: list index out of range 这是出了什么问题?求告知
在nodejs使用 process.argv无反应
在terminal输入node app.js anne 运行后无法显示anne ``` console.log(process.argv) ```
Python脚本 索引越界的问题
# sort data 1: for d in sorted(biom['data'], key=itemgetter(2), reverse=True): name = biom['rows'][d[0]]['id'] if opts.source != 'Subsystems' else biom['rows'][d[0]]['metadata']['ontology'][-1] if len(top_ann) >= opts.top: break if sub_ann and (name not in sub_ann): continue top_ann[name] = d[2] # output data for k, v in sorted(top_ann.items(), key=itemgetter(1), reverse=True): safe_print("%s\t%d\n" %(k, v)) return 0 2:if __name__ == "__main__": sys.exit( main(sys.argv) ) 提示两处错误,1,2。 for d in sorted(biom['data'], key=itemgetter(2), reverse=True): IndexError: list index out of range
timeit,Timer 传入带多参数函数,提示参数未定义
写了个归并排序,在此基础上做了一个修改版本,相比较两个版本的耗时,结果运行的时候却提示lis没有定义: 代码如下: ``` from timeit import Timer def back_sort(lis): n= len(lis) if n == 1: return (lis) mid = n//2 left_sorted = back_sort(lis[:mid]) right_sorted = back_sort(lis[mid:]) n_left = len(left_sorted) n_right = len(right_sorted) left_start = 0 right_start = 0 merged_lis = [] while left_start < n_left and right_start <n_right: if left_sorted[left_start] <= right_sorted[right_start]: merged_lis.append(left_sorted[left_start]) left_start += 1 else: merged_lis.append(right_sorted[right_start]) right_start += 1 merged_lis += left_sorted[left_start:] merged_lis += right_sorted[right_start:] return merged_lis def merge_sort(lis,start,end): if start == end: return [lis[start]] mid = (start+end)//2 right_sorted = merge_sort(lis,mid+1,end) left_sorted = merge_sort(lis,start,mid) n_left = len(left_sorted) n_right = len(right_sorted) left_start = 0 right_start = 0 merged_lis = [] while left_start < n_left and right_start <n_right: if left_sorted[left_start] <= right_sorted[right_start]: merged_lis.append(left_sorted[left_start]) left_start += 1 else: merged_lis.append(right_sorted[right_start]) right_start += 1 merged_lis += left_sorted[left_start:] merged_lis += right_sorted[right_start:] #print(merged_lis) return merged_lis if __name__ == "__main__": lis = [49,38,65,97,76,13,27,49] n = len(lis)-1 print(back_sort(lis)) print(merge_sort(lis,0,n)) t1 = Timer('back_sort(lis)', 'from __main__ import back_sort') t2 = Timer('merge_sort(lis,0,n)', 'from __main__ import merge_sort') print(t1.timeit(number=1000)) print(t2.timeit(number=1000)) ``` 源码如下: ``` #! /usr/bin/env python3 """Tool for measuring execution time of small code snippets. This module avoids a number of common traps for measuring execution times. See also Tim Peters' introduction to the Algorithms chapter in the Python Cookbook, published by O'Reilly. Library usage: see the Timer class. Command line usage: python timeit.py [-n N] [-r N] [-s S] [-t] [-c] [-p] [-h] [--] [statement] Options: -n/--number N: how many times to execute 'statement' (default: see below) -r/--repeat N: how many times to repeat the timer (default 3) -s/--setup S: statement to be executed once initially (default 'pass') -p/--process: use time.process_time() (default is time.perf_counter()) -t/--time: use time.time() (deprecated) -c/--clock: use time.clock() (deprecated) -v/--verbose: print raw timing results; repeat for more digits precision -h/--help: print this usage message and exit --: separate options from statement, use when statement starts with - statement: statement to be timed (default 'pass') A multi-line statement may be given by specifying each line as a separate argument; indented lines are possible by enclosing an argument in quotes and using leading spaces. Multiple -s options are treated similarly. If -n is not given, a suitable number of loops is calculated by trying successive powers of 10 until the total time is at least 0.2 seconds. Note: there is a certain baseline overhead associated with executing a pass statement. It differs between versions. The code here doesn't try to hide it, but you should be aware of it. The baseline overhead can be measured by invoking the program without arguments. Classes: Timer Functions: timeit(string, string) -> float repeat(string, string) -> list default_timer() -> float """ import gc import sys import time import itertools __all__ = ["Timer", "timeit", "repeat", "default_timer"] dummy_src_name = "<timeit-src>" default_number = 1000000 default_repeat = 3 default_timer = time.perf_counter # Don't change the indentation of the template; the reindent() calls # in Timer.__init__() depend on setup being indented 4 spaces and stmt # being indented 8 spaces. template = """ def inner(_it, _timer): {setup} _t0 = _timer() for _i in _it: {stmt} _t1 = _timer() return _t1 - _t0 """ def reindent(src, indent): """Helper to reindent a multi-line statement.""" return src.replace("\n", "\n" + " "*indent) def _template_func(setup, func): """Create a timer function. Used if the "statement" is a callable.""" def inner(_it, _timer, _func=func): setup() _t0 = _timer() for _i in _it: _func() _t1 = _timer() return _t1 - _t0 return inner class Timer: """Class for timing execution speed of small code snippets. The constructor takes a statement to be timed, an additional statement used for setup, and a timer function. Both statements default to 'pass'; the timer function is platform-dependent (see module doc string). To measure the execution time of the first statement, use the timeit() method. The repeat() method is a convenience to call timeit() multiple times and return a list of results. The statements may contain newlines, as long as they don't contain multi-line string literals. """ def __init__(self, stmt="pass", setup="pass", timer=default_timer): """Constructor. See class doc string.""" self.timer = timer ns = {} if isinstance(stmt, str): stmt = reindent(stmt, 8) if isinstance(setup, str): setup = reindent(setup, 4) src = template.format(stmt=stmt, setup=setup) elif callable(setup): src = template.format(stmt=stmt, setup='_setup()') ns['_setup'] = setup else: raise ValueError("setup is neither a string nor callable") self.src = src # Save for traceback display code = compile(src, dummy_src_name, "exec") exec(code, globals(), ns) self.inner = ns["inner"] elif callable(stmt): self.src = None if isinstance(setup, str): _setup = setup def setup(): exec(_setup, globals(), ns) elif not callable(setup): raise ValueError("setup is neither a string nor callable") self.inner = _template_func(setup, stmt) else: raise ValueError("stmt is neither a string nor callable") def print_exc(self, file=None): """Helper to print a traceback from the timed code. Typical use: t = Timer(...) # outside the try/except try: t.timeit(...) # or t.repeat(...) except: t.print_exc() The advantage over the standard traceback is that source lines in the compiled template will be displayed. The optional file argument directs where the traceback is sent; it defaults to sys.stderr. """ import linecache, traceback if self.src is not None: linecache.cache[dummy_src_name] = (len(self.src), None, self.src.split("\n"), dummy_src_name) # else the source is already stored somewhere else traceback.print_exc(file=file) def timeit(self, number=default_number): """Time 'number' executions of the main statement. To be precise, this executes the setup statement once, and then returns the time it takes to execute the main statement a number of times, as a float measured in seconds. The argument is the number of times through the loop, defaulting to one million. The main statement, the setup statement and the timer function to be used are passed to the constructor. """ it = itertools.repeat(None, number) gcold = gc.isenabled() gc.disable() try: timing = self.inner(it, self.timer) finally: if gcold: gc.enable() return timing def repeat(self, repeat=default_repeat, number=default_number): """Call timeit() a few times. This is a convenience function that calls the timeit() repeatedly, returning a list of results. The first argument specifies how many times to call timeit(), defaulting to 3; the second argument specifies the timer argument, defaulting to one million. Note: it's tempting to calculate mean and standard deviation from the result vector and report these. However, this is not very useful. In a typical case, the lowest value gives a lower bound for how fast your machine can run the given code snippet; higher values in the result vector are typically not caused by variability in Python's speed, but by other processes interfering with your timing accuracy. So the min() of the result is probably the only number you should be interested in. After that, you should look at the entire vector and apply common sense rather than statistics. """ r = [] for i in range(repeat): t = self.timeit(number) r.append(t) return r def timeit(stmt="pass", setup="pass", timer=default_timer, number=default_number): """Convenience function to create Timer object and call timeit method.""" return Timer(stmt, setup, timer).timeit(number) def repeat(stmt="pass", setup="pass", timer=default_timer, repeat=default_repeat, number=default_number): """Convenience function to create Timer object and call repeat method.""" return Timer(stmt, setup, timer).repeat(repeat, number) def main(args=None, *, _wrap_timer=None): """Main program, used when run as a script. The optional 'args' argument specifies the command line to be parsed, defaulting to sys.argv[1:]. The return value is an exit code to be passed to sys.exit(); it may be None to indicate success. When an exception happens during timing, a traceback is printed to stderr and the return value is 1. Exceptions at other times (including the template compilation) are not caught. '_wrap_timer' is an internal interface used for unit testing. If it is not None, it must be a callable that accepts a timer function and returns another timer function (used for unit testing). """ if args is None: args = sys.argv[1:] import getopt try: opts, args = getopt.getopt(args, "n:s:r:tcpvh", ["number=", "setup=", "repeat=", "time", "clock", "process", "verbose", "help"]) except getopt.error as err: print(err) print("use -h/--help for command line help") return 2 timer = default_timer stmt = "\n".join(args) or "pass" number = 0 # auto-determine setup = [] repeat = default_repeat verbose = 0 precision = 3 for o, a in opts: if o in ("-n", "--number"): number = int(a) if o in ("-s", "--setup"): setup.append(a) if o in ("-r", "--repeat"): repeat = int(a) if repeat <= 0: repeat = 1 if o in ("-t", "--time"): timer = time.time if o in ("-c", "--clock"): timer = time.clock if o in ("-p", "--process"): timer = time.process_time if o in ("-v", "--verbose"): if verbose: precision += 1 verbose += 1 if o in ("-h", "--help"): print(__doc__, end=' ') return 0 setup = "\n".join(setup) or "pass" # Include the current directory, so that local imports work (sys.path # contains the directory of this script, rather than the current # directory) import os sys.path.insert(0, os.curdir) if _wrap_timer is not None: timer = _wrap_timer(timer) t = Timer(stmt, setup, timer) if number == 0: # determine number so that 0.2 <= total time < 2.0 for i in range(1, 10): number = 10**i try: x = t.timeit(number) except: t.print_exc() return 1 if verbose: print("%d loops -> %.*g secs" % (number, precision, x)) if x >= 0.2: break try: r = t.repeat(repeat, number) except: t.print_exc() return 1 best = min(r) if verbose: print("raw times:", " ".join(["%.*g" % (precision, x) for x in r])) print("%d loops," % number, end=' ') usec = best * 1e6 / number if usec < 1000: print("best of %d: %.*g usec per loop" % (repeat, precision, usec)) else: msec = usec / 1000 if msec < 1000: print("best of %d: %.*g msec per loop" % (repeat, precision, msec)) else: sec = msec / 1000 print("best of %d: %.*g sec per loop" % (repeat, precision, sec)) return None if __name__ == "__main__": sys.exit(main()) ``` 多次尝试无果,把源码翻出来再看,结果然并卵以我2毛实力并未查出个所以然。 还请大神指点。
在中国程序员是青春饭吗?
今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...
我在支付宝花了1分钟,查到了女朋友的开房记录!
在大数据时代下,不管你做什么都会留下蛛丝马迹,只要学会把各种软件运用到极致,捉奸简直轻而易举。今天就来给大家分享一下,什么叫大数据抓出轨。据史料证明,马爸爸年轻时曾被...
程序员请照顾好自己,周末病魔差点一套带走我。
程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。
卸载 x 雷某度!GitHub 标星 1.5w+,从此我只用这款全能高速下载工具!
作者 | Rocky0429 来源 | Python空间 大家好,我是 Rocky0429,一个喜欢在网上收集各种资源的蒟蒻… 网上资源眼花缭乱,下载的方式也同样千奇百怪,比如 BT 下载,磁力链接,网盘资源等等等等,下个资源可真不容易,不一样的方式要用不同的下载软件,因此某比较有名的 x 雷和某度网盘成了我经常使用的工具。 作为一个没有钱的穷鬼,某度网盘几十 kb 的下载速度让我...
20道你必须要背会的微服务面试题,面试一定会被问到
写在前面: 在学习springcloud之前大家一定要先了解下,常见的面试题有那块,然后我们带着问题去学习这个微服务技术,那么就会更加理解springcloud技术。如果你已经学了springcloud,那么在准备面试的时候,一定要看看看这些面试题。 文章目录1、什么是微服务?2、微服务之间是如何通讯的?3、springcloud 与dubbo有哪些区别?4、请谈谈对SpringBoot 和S...
为什么猝死的都是程序员,基本上不见产品经理猝死呢?
相信大家时不时听到程序员猝死的消息,但是基本上听不到产品经理猝死的消息,这是为什么呢? 我们先百度搜一下:程序员猝死,出现将近700多万条搜索结果: 搜索一下:产品经理猝死,只有400万条的搜索结果,从搜索结果数量上来看,程序员猝死的搜索结果就比产品经理猝死的搜索结果高了一倍,而且从下图可以看到,首页里面的五条搜索结果,其实只有两条才是符合条件。 所以程序员猝死的概率真的比产品经理大,并不是错...
毕业5年,我问遍了身边的大佬,总结了他们的学习方法
我问了身边10个大佬,总结了他们的学习方法,原来成功都是有迹可循的。
推荐10个堪称神器的学习网站
每天都会收到很多读者的私信,问我:“二哥,有什么推荐的学习网站吗?最近很浮躁,手头的一些网站都看烦了,想看看二哥这里有什么新鲜货。” 今天一早做了个恶梦,梦到被老板辞退了。虽然说在我们公司,只有我辞退老板的份,没有老板辞退我这一说,但是还是被吓得 4 点多都起来了。(主要是因为我掌握着公司所有的核心源码,哈哈哈) 既然 4 点多起来,就得好好利用起来。于是我就挑选了 10 个堪称神器的学习网站,推...
这些软件太强了,Windows必装!尤其程序员!
Windows可谓是大多数人的生产力工具,集娱乐办公于一体,虽然在程序员这个群体中都说苹果是信仰,但是大部分不都是从Windows过来的,而且现在依然有很多的程序员用Windows。 所以,今天我就把我私藏的Windows必装的软件分享给大家,如果有一个你没有用过甚至没有听过,那你就赚了????,这可都是提升你幸福感的高效率生产力工具哦! 走起!???? NO、1 ScreenToGif 屏幕,摄像头和白板...
阿里面试,面试官没想到一个ArrayList,我都能跟他扯半小时
我是真的没想到,面试官会这样问我ArrayList。
曾经优秀的人,怎么就突然不优秀了。
职场上有很多辛酸事,很多合伙人出局的故事,很多技术骨干被裁员的故事。说来模板都类似,曾经是名校毕业,曾经是优秀员工,曾经被领导表扬,曾经业绩突出,然而突然有一天,因为种种原因,被裁员了,...
大学四年因为知道了这32个网站,我成了别人眼中的大神!
依稀记得,毕业那天,我们导员发给我毕业证的时候对我说“你可是咱们系的风云人物啊”,哎呀,别提当时多开心啦????,嗯,我们导员是所有导员中最帅的一个,真的???? 不过,导员说的是实话,很多人都叫我大神的,为啥,因为我知道这32个网站啊,你说强不强????,这次是绝对的干货,看好啦,走起来! PS:每个网站都是学计算机混互联网必须知道的,真的牛杯,我就不过多介绍了,大家自行探索,觉得没用的,尽管留言吐槽吧???? 社...
良心推荐,我珍藏的一些Chrome插件
上次搬家的时候,发了一个朋友圈,附带的照片中不小心暴露了自己的 Chrome 浏览器插件之多,于是就有小伙伴评论说分享一下我觉得还不错的浏览器插件。 我下面就把我日常工作和学习中经常用到的一些 Chrome 浏览器插件分享给大家,随便一个都能提高你的“生活品质”和工作效率。 Markdown Here Markdown Here 可以让你更愉快的写邮件,由于支持 Markdown 直接转电子邮...
看完这篇HTTP,跟面试官扯皮就没问题了
我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟、醍醐灌顶的感觉。 最初在有网络之前,我们的电脑都是单机的,单机系统是孤立的,我还记得 05 年前那会儿家里有个电脑,想打电脑游戏还得两个人在一个电脑上玩儿,及其不方便。我就想为什么家里人不让上网,我的同学 xxx 家里有网,每...
2020 年,大火的 Python 和 JavaScript 是否会被取而代之?
Python 和 JavaScript 是目前最火的两大编程语言,但是2020 年,什么编程语言将会取而代之呢? 作者 |Richard Kenneth Eng 译者 |明明如月,责编 | 郭芮 出品 | CSDN(ID:CSDNnews) 以下为译文: Python 和 JavaScript 是目前最火的两大编程语言。然而,他们不可能永远屹立不倒。最终,必将像其他编程语言一...
史上最全的IDEA快捷键总结
现在Idea成了主流开发工具,这篇博客对其使用的快捷键做了总结,希望对大家的开发工作有所帮助。
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
谁是华为扫地僧?
是的,华为也有扫地僧!2020年2月11-12日,“养在深闺人不知”的华为2012实验室扫地僧们,将在华为开发者大会2020(Cloud)上,和大家见面。到时,你可以和扫地僧们,吃一个洋...
AI 没让人类失业,搞 AI 的人先失业了
最近和几个 AI 领域的大佬闲聊 根据他们讲的消息和段子 改编出下面这个故事 如有雷同 都是巧合 1. 老王创业失败,被限制高消费 “这里写我跑路的消息实在太夸张了。” 王葱葱哼笑一下,把消息分享给群里。 阿杰也看了消息,笑了笑。在座几位也都笑了。 王葱葱是个有名的人物,21岁那年以全额奖学金进入 KMU 攻读人工智能博士,累计发表论文 40 余篇,个人技术博客更是成为深度学习领域内风向标。 ...
2020年,冯唐49岁:我给20、30岁IT职场年轻人的建议
点击“技术领导力”关注∆每天早上8:30推送 作者|Mr.K 编辑| Emma 来源|技术领导力(ID:jishulingdaoli) 前天的推文《冯唐:职场人35岁以后,方法论比经验重要》,收到了不少读者的反馈,觉得挺受启发。其实,冯唐写了不少关于职场方面的文章,都挺不错的。可惜大家只记住了“春风十里不如你”、“如何避免成为油腻腻的中年人”等不那么正经的文章。 本文整理了冯...
最全最强!世界大学计算机专业排名总结!
我正在参与CSDN200进20,希望得到您的支持,扫码续投票5次。感谢您! (为表示感谢,您投票后私信我,我把我总结的人工智能手推笔记和思维导图发送给您,感谢!) 目录 泰晤士高等教育世界大学排名 QS 世界大学排名 US News 世界大学排名 世界大学学术排名(Academic Ranking of World Universities) 泰晤士高等教育世界大学排名 中国共...
作为一名大学生,如何在B站上快乐的学习?
B站是个宝,谁用谁知道???? 作为一名大学生,你必须掌握的一项能力就是自学能力,很多看起来很牛X的人,你可以了解下,人家私底下一定是花大量的时间自学的,你可能会说,我也想学习啊,可是嘞,该学习啥嘞,不怕告诉你,互联网时代,最不缺的就是学习资源,最宝贵的是啥? 你可能会说是时间,不,不是时间,而是你的注意力,懂了吧! 那么,你说学习资源多,我咋不知道,那今天我就告诉你一个你必须知道的学习的地方,人称...
那些年,我们信了课本里的那些鬼话
教材永远都是有错误的,从小学到大学,我们不断的学习了很多错误知识。 斑羚飞渡 在我们学习的很多小学课文里,有很多是错误文章,或者说是假课文。像《斑羚飞渡》: 随着镰刀头羊的那声吼叫,整个斑羚群迅速分成两拨,老年斑羚为一拨,年轻斑羚为一拨。 就在这时,我看见,从那拨老斑羚里走出一只公斑羚来。公斑羚朝那拨年轻斑羚示意性地咩了一声,一只半大的斑羚应声走了出来。一老一少走到伤心崖,后退了几步,突...
使用 Python 和百度语音识别生成视频字幕
文章目录从视频中提取音频根据静音对音频分段使用百度语音识别获取 Access Token使用 Raw 数据进行合成生成字幕总结 从视频中提取音频 安装 moviepy pip install moviepy 相关代码: audio_file = work_path + '\\out.wav' video = VideoFileClip(video_file) video.audio.write_...
一个程序在计算机中是如何运行的?超级干货!!!
强烈声明:本文很干,请自备茶水!???? 开门见山,咱不说废话! 你有没有想过,你写的程序,是如何在计算机中运行的吗?比如我们搞Java的,肯定写过这段代码 public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } ...
【蘑菇街技术部年会】程序员与女神共舞,鼻血再次没止住。(文末内推)
蘑菇街技术部的年会,别开生面,一样全是美女。
那个在阿里养猪的工程师,5年了……
简介: 在阿里,走过1825天,没有趴下,依旧斗志满满,被称为“五年陈”。他们会被授予一枚戒指,过程就叫做“授戒仪式”。今天,咱们听听阿里的那些“五年陈”们的故事。 下一个五年,猪圈见! 我就是那个在养猪场里敲代码的工程师,一年多前我和20位工程师去了四川的猪场,出发前总架构师慷慨激昂的说:同学们,中国的养猪产业将因为我们而改变。但到了猪场,发现根本不是那么回事:要个WIFI,没有;...
为什么程序猿都不愿意去外包?
分享外包的组织架构,盈利模式,亲身经历,以及根据一些外包朋友的反馈,写了这篇文章 ,希望对正在找工作的老铁有所帮助
Java校招入职华为,半年后我跑路了
何来 我,一个双非本科弟弟,有幸在 19 届的秋招中得到前东家华为(以下简称 hw)的赏识,当时秋招签订就业协议,说是入了某 java bg,之后一系列组织架构调整原因等等让人无法理解的神操作,最终毕业前夕,被通知调往其他 bg 做嵌入式开发(纯 C 语言)。 由于已至于校招末尾,之前拿到的其他 offer 又无法再收回,一时感到无力回天,只得默默接受。 毕业后,直接入职开始了嵌入式苦旅,由于从未...
世界上有哪些代码量很少,但很牛逼很经典的算法或项目案例?
点击上方蓝字设为星标下面开始今天的学习~今天分享四个代码量很少,但很牛逼很经典的算法或项目案例。1、no code 项目地址:https://github.com/kelseyhight...
Python全栈 Linux基础之3.Linux常用命令
Linux对文件(包括目录)有很多常用命令,可以加快开发效率:ls是列出当前目录下的文件列表,选项有-a、-l、-h,还可以使用通配符;c功能是跳转目录,可以使用相对路径和绝对路径;mkdir命令创建一个新的目录,有-p选项,rm删除文件或目录,有-f、-r选项;cp用于复制文件,有-i、-r选项,tree命令可以将目录结构显示出来(树状显示),有-d选项,mv用来移动文件/目录,有-i选项;cat查看文件内容,more分屏显示文件内容,grep搜索内容;>、>>将执行结果重定向到一个文件;|用于管道输出。
立即提问