Python报错'xxx' object has no attribute 'xxx'

小白刚刚接触Python,想使用Python做一个用户注册和登陆的界面,使用pyqt从ui文件转换成py文件,但在转换完成之后执行报错,求大神解答。

-*- coding: utf-8 -*-

Form implementation generated from reading ui file 'sign.ui'

#

Created: Sun Nov 13 17:09:05 2016

by: PyQt4 UI code generator 4.11.3

#

WARNING! All changes made in this file will be lost!

import sys
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)

class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(747, 564)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.label = QtGui.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(50, 30, 211, 61))
self.label.setStyleSheet(_fromUtf8("\n"
"font: 75 22pt \"Microsoft YaHei UI\";"))
self.label.setObjectName(_fromUtf8("label"))
self.label_2 = QtGui.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(50, 120, 81, 18))
self.label_2.setStyleSheet(_fromUtf8("font: 9pt \"Microsoft YaHei UI\";"))
self.label_2.setObjectName(_fromUtf8("label_2"))
self.lineEdit = QtGui.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(50, 150, 331, 25))
self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
self.label_3 = QtGui.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(50, 200, 81, 18))
self.label_3.setStyleSheet(_fromUtf8("font: 9pt \"Microsoft YaHei UI\";"))
self.label_3.setObjectName(_fromUtf8("label_3"))
self.lineEdit_2 = QtGui.QLineEdit(self.centralwidget)
self.lineEdit_2.setGeometry(QtCore.QRect(50, 230, 331, 25))
self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2"))
self.label_4 = QtGui.QLabel(self.centralwidget)
self.label_4.setGeometry(QtCore.QRect(50, 280, 81, 18))
self.label_4.setStyleSheet(_fromUtf8("font: 9pt \"Microsoft YaHei UI\";"))
self.label_4.setObjectName(_fromUtf8("label_4"))
self.lineEdit_3 = QtGui.QLineEdit(self.centralwidget)
self.lineEdit_3.setGeometry(QtCore.QRect(50, 310, 331, 25))
self.lineEdit_3.setObjectName(_fromUtf8("lineEdit_3"))
self.pushButton = QtGui.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(50, 380, 112, 34))
self.pushButton.setStyleSheet(_fromUtf8("font: 9pt \"Microsoft YaHei UI\";\n"
"background-color: rgb(215, 215, 215);"))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 747, 30))
self.menubar.setObjectName(_fromUtf8("menubar"))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName(_fromUtf8("statusbar"))
MainWindow.setStatusBar(self.statusbar)

    self.retranslateUi(MainWindow)
    QtCore.QMetaObject.connectSlotsByName(MainWindow)

def retranslateUi(self, MainWindow):
    MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
    self.label.setText(_translate("MainWindow", "欢迎注册", None))
    self.label_2.setText(_translate("MainWindow", "名字", None))
    self.label_3.setText(_translate("MainWindow", "密码", None))
    self.label_4.setText(_translate("MainWindow", "重复密码", None))
    self.pushButton.setText(_translate("MainWindow", "注册", None))

if name == "__main__":
app = QtGui.QApplication(sys.argv)
Form = QtGui.QWidget()
ui = Ui_MainWindow()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())

Traceback (most recent call last):
File "D:/PyCharm 2016.2.3/example/Sign.py", line 88, in
ui.setupUi(Form)
File "D:/PyCharm 2016.2.3/example/Sign.py", line 64, in setupUi
MainWindow.setCentralWidget(self.centralwidget)
AttributeError: 'QWidget' object has no attribute 'setCentralWidget'

2个回答

函数名发生变化了,或者转换工具需要升级

检查一下 对齐情况, 我就因为没对齐的时候会出现这种情况, 确定这个类中有这个东西

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Bug处理之执行自己编写代码中出现的AttributeError: ‘XXX’ object has no attribute’xxx’
操作系统Windows10.0; PythonIDE:Pycharm2018.02 Python版本:python3.6(anaconda平台) 自己编写脚本搭建股票数据库 问题描述:自己编写python脚本解决一些数据库搭建过程中的繁琐过程,方便以后重复调用; 编写的类在导入应用时报错AttributeError: ‘XXX’ object has no attribute’xxx’,...
python报错has no attribute '__trunc__'
rn我想写一个在数组中可以交换元素句子,就是如果第i个空了的话下一个补上这种,不太会python。纯小白,不太知道怎么交换array里的元素rnfor i in xrange(self.job_slot):rn index1=irn index2=i+1rn a = self.job_slot[index2]rn self.job_slot[index1]=arn 报的错是JobSlot instance has no attribute '__trunc__'rn还有一个问题是还有一次调试的时候i+1出界了,不知道这种怎么解决,拜托各位大神了[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/2.gif][/img]
'module' object has no attribute 'ml',报错
import cv2rnimport cPicklernimport numpy as nprnimport gziprnrnrndef load_data():rn mnist = gzip.open('data/mnist.pkl.gz', 'rb')rn training_data, classification_data, test_data = cPickle.load(mnist)rn mnist.close()rn return (training_data, classification_data, test_data)rnrndef wrap_data():rn tr_d, va_d, te_d = load_data()rn training_inputs = [np.reshape(x, (784, 1)) for x in tr_d[0]]rn training_results = [vectorized_result(y) for y in tr_d[1]]rn training_data = zip(training_inputs, training_results)rn validation_inputs = [np.reshape(x, (784, 1)) for x in va_d[0]]rn validation_data = zip(validation_inputs, va_d[1])rn test_inputs = [np.reshape(x, (784, 1)) for x in te_d[0]]rn test_data = zip(test_inputs, te_d[1])rn return (training_data, validation_data, test_data)rnrndef vectorized_result(j):rn e = np.zeros((10, 1))rn e[j] = 1.0rn return ernrn#基于MNIST创建一个用于手写数字识别的ANNrndef create_ANN(hidden = 20):rn ann = cv2.ml.ANN_MLP_create()rn ann.setLayerSizes(np.array([784, hidden, 10]))
关于Python中使用pymysql驱动连接数据库时报"XXX" object has no attribute ‘translate’的解决方法
    最近在使用flask开发时,用了pymysql驱动来连接数据库,但是在使用枚举类型作为数据库条件来对数据库进行查找数据时(如下图):        报出了以下错误:    原因:     数据库中使用的pending的类型为int型,而图中的PendingStatus.Success为枚举型, 与mysql中不一致,导致数据无法写入mysql 解决方法:     修改数据类型, 这里我只在...
list object has no attribute location python
我刚使用python写程序,然后总是报错list object has no attribute location,为什么?我应该怎么处理呢?n
Python 运行报错: 'WebDriver' object has no attribute 'find_element_by_Xpath'
[img=https://img-bbs.csdn.net/upload/201812/25/1545720592_267528.png][/img]
求助,python的'dict' object has no attribute 'key'
class Fridge:rnrnrndef __init__(self,items=):rnif type(items)!=type():rnraise TypeError("Fridge requires a dictionary but was given %s" %type(items))rnself.items=itemsrnreturnrnrnrndef __add_multi(self,food_name,quantity):rnif (not food_name in self.items):rnself.items[food_name] = 0rnself.items[food_name]=self.items[food_name] + quantityrnrnrndef add_one(self,food_name):rnif type(food_name)!=type(''):rnraise TypeError("add_one requires a string, given a %s"%type(food_name))rnelse:rnself.__add_multi(food_name,1)rnreturn Truernrnrndef add_many(self,food_dict):rnif type(food_dict)!=type():rnraise TypeError("add_many requires a dictionary, got a %s" %type(food_dict))rnfor item in food_dict.key():rnself.__add_multi(item,food_dict[item])rnreturnrn错误:rnTraceback (most recent call last):rnFile "", line 1, in rnFile "Fridge.py", line 26, in add_manyrnfor item in food_dict.key():rnAttributeError: 'dict' object has no attribute 'key'
python报错'DataFrame' object has no attribute 'sort',求解决方法!!
在看数据挖掘的书,运行下面程序以后报错(程序是直接复制的应该没问题):rn[code=python]rn#-*- coding: utf-8 -*-rn#逻辑回归 自动建模rnimport pandas as pdrnrn#参数初始化rnfilename = '../data/bankloan.xls'rndata = pd.read_excel(filename)rnx = data.iloc[:,:8].as_matrix()rny = data.iloc[:,8].as_matrix()rnrnfrom sklearn.linear_model import LogisticRegression as LRrnfrom sklearn.linear_model import RandomizedLogisticRegression as RLR rnrlr = RLR() #建立随机逻辑回归模型,筛选变量rnrlr.fit(x, y) #训练模型rnrlr.get_support() #获取特征筛选结果,也可以通过.scores_方法获取各个特征的分数rnprint(u'通过随机逻辑回归模型筛选特征结束。')rnprint(u'有效特征为:%s' % ','.join(data.columns[rlr.get_support()]))rnx = data[data.columns[rlr.get_support()]].as_matrix() #筛选好特征rnrnlr = LR() #建立逻辑货柜模型rnlr.fit(x, y) #用筛选后的特征数据来训练模型rnprint(u'逻辑回归模型训练结束。')rnprint(u'模型的平均正确率为:%s' % lr.score(x, y)) #给出模型的平均正确率,本例为81.4%rn[/code]rnrn运行后显示AttributeError: 'DataFrame' object has no attribute 'sort'rnrn但在别人电脑上运行就没问题,python2和python3我都试了都是这个错误,求指点!!!
python英文去停用词,报错 'str' object has no attribute
各位大神,请问这个错误啥子意思呀?n'str' object has no attribute 'word'n![图片说明](https://img-ask.csdn.net/upload/201702/11/1486818276_296519.jpg)
python json报错:AttributeError: 'str' object has no attribute 'read'
#!/usr/bin/pythonrn#coding=gbkrnimport osrnimport json rnrnRes='["brief":"ooooo","class_extid":13,"create_time":你好,"face_id":4,"flag":6777217,"flag_ext":0,"level":0,"max_member":100,"memo":"m~F~M0m~Zm~@~B","name":"10502","option":2,"ul":["flag":4,"u":285,"flag":4,"u":35]]' rnrnqDic = json.load(Res)rnprint qDicrnfor i in qDic:rn print i["class_extid"]rn print i["flag"]rn for j in i["ul"]:rn print str(j["flag"]) + "===" + str(j["u"])rnrn执行后报错:rnTraceback (most recent call last):rn File "my.py", line 7, in rn qDic = json.load(Res)rn File "/usr/lib/python2.6/json/__init__.py", line 264, in loadrn return loads(fp.read(),rnAttributeError: 'str' object has no attribute 'read'rnrn请高手指点,万分感谢
spring cglib报错 xxx cannot be cast to xxx
[b][size=18px]1, 想使用 ehcache + spring jdbc 实现查询结果缓存,现在功能都实现了,但是使用时报错[/size]:[/b]rnrn[code=java]rnjava.lang.ClassCastException: com.hbzx.bean.ShopViewCountBean cannot be cast to java.util.Listrn at com.hbzx.dao.ShopViewCountDao$$EnhancerBySpringCGLIB$$1c70ff76.queryAll()rn at com.hbzx.service.ShopViewCountService.fillHistory(ShopViewCountService.java:143)rn at com.hbzx.service.ShopViewCountService.query(ShopViewCountService.java:46)rn at com.hbzx.controller.UserCommissionController.getMyShopLog(UserCommissionController.java:45)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)rn at java.lang.reflect.Method.invoke(Method.java:483)rn at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)rn at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)rn at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)rn at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:743)rn at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:672)rn at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:82)rn at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:919)rn at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:851)rn at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)rn at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)rn at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:202)rn at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:180)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)rn at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)rn at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537)rn at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085)rn at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)rn at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)rn at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556)rn at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513)rn at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)rn at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)rn at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)rn at java.lang.Thread.run(Thread.java:745)rn[/code]rnrn
mybatis 报错 There is no getter for property named 'xxx' in 'xxx'
[code=text]Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'is_partner' in 'class com.xfj.base.bossapp.domain.SellerAgent'rn at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:333)rn at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:160)rn at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:151)rn at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:44)rn at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:123)rn at org.apache.ibatis.builder.xml.dynamic.DynamicContext$ContextMap.get(DynamicContext.java:89)rn at org.apache.ibatis.builder.xml.dynamic.DynamicContext$ContextAccessor.getProperty(DynamicContext.java:107)rn at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1657)rn at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:92)rn at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)rn at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)rn at org.apache.ibatis.ognl.ASTNotEq.getValueBody(ASTNotEq.java:49)rn at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)rn at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)rn at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:333)rn at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:413)rn at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:395)rn at org.apache.ibatis.builder.xml.dynamic.OgnlCache.getValue(OgnlCache.java:42)rn at org.apache.ibatis.builder.xml.dynamic.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32)rn at org.apache.ibatis.builder.xml.dynamic.IfSqlNode.apply(IfSqlNode.java:30)rn at org.apache.ibatis.builder.xml.dynamic.MixedSqlNode.apply(MixedSqlNode.java:29)rn at org.apache.ibatis.builder.xml.dynamic.TrimSqlNode.apply(TrimSqlNode.java:42)rn at org.apache.ibatis.builder.xml.dynamic.MixedSqlNode.apply(MixedSqlNode.java:29)rn at org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:37)rn at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:241)rn at org.apache.ibatis.executor.statement.BaseStatementHandler.(BaseStatementHandler.java:61)rn at org.apache.ibatis.executor.statement.PreparedStatementHandler.(PreparedStatementHandler.java:36)rn at org.apache.ibatis.executor.statement.RoutingStatementHandler.(RoutingStatementHandler.java:42)rn at org.apache.ibatis.session.Configuration.newStatementHandler(Configuration.java:348)rn at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:43)rn at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)rn at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)rn at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:145)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)rn at java.lang.reflect.Method.invoke(Method.java:606)rn at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:355)rn ... 176 more[/code]rnrn找了好久都找不到什么问题,用的方法是用工具生成的update方法
'int' object has no attribute '__getitem__'
小白最近正在学Python 数据挖掘入门与实践一书,在书的1.3章节亲和性分析中遇到一个问题,久久不能解决:rn原书第9页第11行: if sample[premise]==0: continue 代码运行时提示这行报错,错误类型如标题。rn百度上查了好久,感觉没有给sample这个类定义getitem,具体操作应该怎么做?拜托大家了。
'NoneType' object has no attribute 'path'
用python3.5+selenium+firefox49.0 练习自动化测试rn以下是代码内容rnrn#coding=utf-8rnfrom selenium import webdriverrnrndriver = webdriver.Firefox()rndriver.get("http://www.baidu.com")rnrndriver.find_element_by_id("kw").send_keys("csdn")rndriver.find_element_by_id("su").click()rnrndriver.quit()rnrn执行成功了,没报错,但是报了这么个信息:rn'NoneType' object has no attribute 'path'rn查了好多资料啥的,都没个准确的方法,一开始我以为这个代码有问题,又写了别的用例,仍旧是能执行成功,但依然显示这个提示rn网上有些说是geckodriver没配置好,但是我是放到了python安装目录下的,python目录本身就在环境变量中,而且我用例也执行成功了rnrn哪位大神來指点一下?rn
'JSONDecoder' object has no attribute 'object_pairs_hook'
File "/usr/local/lib/python2.7/dist-packages/rklib-0.1.1_alpha-py2.7.egg/rklib/common/simplejson/decoder.py", line 322, in __init__rnrnAttributeError: 'JSONDecoder' object has no attribute 'object_pairs_hook'rnrn是否有兄台遇到过?rn版本的问题吗?
'Datasets' object has no attribute 'train_step'
import tensorflow as tfnfrom tensorflow.examples.tutorials.mnist import input_datanimport mnist_forwardnimport osnnBATAH_SIZE = 200nLEARNING_RATE_BASE = 0.1nLEARNING_RATE_DECAY = 0.99nREGULARIZER = 0.0001nSTEPS = 50000nMOVING_AVERAGE_DECAY = 0.99nMODEL_SAVE_PATH = "./model/"nMODEL_NAME = "mnist_model"nndef backward(mnist):nn x = tf.placeholder(tf.float32, [None, mnist_forward.INPUT_NODE])n y_ = tf.placeholder(tf.float32, [None, mnist_forward.OUTPUT_NODE])n y = mnist_forward.forward(x, REGULARIZER)n global_step = tf.Variable(0, trainable=False)nn ce = tf.nn.sparse_softmax_cross_entropy_with_logits(logits=y, labels=tf.arg_max(y_, 1))n cem = tf.reduce_mean(ce)n loss = cem + tf.add_n(tf.get_collection('losses'))nn learning_rate = tf.train.exponential_decay(LEARNING_RATE_BASE, global_step, mnist.train.num_examples / BATAH_SIZE,n LEARNING_RATE_DECAY, staircase=True)nn train_step = tf.train.GradientDescentOptimizer(learning_rate).minimize(loss, global_step=global_step)nn ema = tf.train.ExponentialMovingAverage(MOVING_AVERAGE_DECAY, global_step)n ema_op = ema.apply(tf.trainable_variables())n with tf.control_dependencies([train_step, ema_op]):n train_op = tf.no_op(name='train')nn saver = tf.train.Saver()nn with tf.Session() as sess:n init_op = tf.global_variables_initializer()n sess.run(init_op)nn for i in range(STEPS):n xs, ys = mnist.train_step.next_batch(BATAH_SIZE)n _, loss_value, step = sess.run([train_op, loss, global_step], feed_dict=x: xs, y_: ys)n if i % 1000 == 0:n print("After %d training step(s), loss on training batch is %g." % (step, loss_value))n saver.save(sess, os.path.join(MODEL_SAVE_PATH, MODEL_NAME), global_step=global_step)nndef main():n mnist = input_data.read_data_sets("./data/", one_hot=True)n backward(mnist)nnif __name__ == '__main__':n main()nn运行程序后报错:nn File "C:/Users/98382/PycharmProjects/minst/mnist_backward.py", line 54, in n main()n File "C:/Users/98382/PycharmProjects/minst/mnist_backward.py", line 51, in mainn backward(mnist)n File "C:/Users/98382/PycharmProjects/minst/mnist_backward.py", line 43, in backwardn xs, ys = mnist.train_step.next_batch(BATAH_SIZE)nAttributeError: 'Datasets' object has no attribute 'train_step'nn
'NoneType' object has no attribute '__getitem__'
按照《Ubuntu12.04.2 OpenStack Grizzly 安装(Bridge)》进行openstack安装,在配置keystone的时候,总是出现如下错误:rn> bash keystone.shrn 'NoneType' object has no attribute '__getitem__'rnrn不知道错在了哪里?rnrn《Ubuntu12.04.2 OpenStack Grizzly 安装(Bridge)》rnhttp://www.chenshake.com/ubuntu12-04-2-installed-openstack-grizzly-bridge-mode
xxx
xxx
xxx 和 xxx 有什么区别?
求高手指点。rnxxx 和 xxx 有什么区别?rnrn今天我测试一个web工程是老报错。 rn把返回上一级rn换成返回上一级rn居然就好。不知到之前为什么会报错。望高手教导。rnrnrn
XXX
请教 getcommmodemstatus 的使用方法
Xxx
C# 仿QQ截图程序 winformrnusing System;rnusing System.Collections.Generic;rnusing System.ComponentModel;rnusing System.Data;rnusing System.Drawing;rnusing System.Text;rnusing System.Windows.Forms;rnrnnamespace Clientrnrn public partial class Catch : Formrn rn public Catch()rn rn InitializeComponent();rn rnrn 用户变量#region 用户变量rn private Point DownPoint = Point.Empty;//记录鼠标按下坐标,用来确定绘图起点rn private bool CatchFinished = false;//用来表示是否截图完成rn private bool CatchStart = false;//表示截图开始rn private Bitmap originBmp;//用来保存原始图像rn private Rectangle CatchRect;//用来保存截图的矩形rn #endregionrnrn //窗体初始化操作rn private void Catch_Load(object sender, EventArgs e)rn rn this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);rn this.UpdateStyles();rn //以上两句是为了设置控件样式为双缓冲,这可以有效减少图片闪烁的问题,关于这个大家可以自己去搜索下rn originBmp = new Bitmap(this.BackgroundImage);//BackgroundImage为全屏图片,我们另用变量来保存全屏图片rn rnrn //鼠标右键点击结束截图rn private void Catch_MouseClick(object sender, MouseEventArgs e)rn rn if (e.Button == MouseButtons.Right)rn rn this.DialogResult = DialogResult.OK;rn this.Close();rn rn rnrn //鼠标左键按下时动作rn private void Catch_MouseDown(object sender, MouseEventArgs e)rn rn if (e.Button == MouseButtons.Left)rn rn if (!CatchStart)rn //如果捕捉没有开始rn CatchStart = true;rn DownPoint = new Point(e.X, e.Y);//保存鼠标按下坐标rn rn rn rnrn private void Catch_MouseMove(object sender, MouseEventArgs e)rn rn if (CatchStart)rn //如果捕捉开始rn Bitmap destBmp = (Bitmap)originBmp.Clone();//新建一个图片对象,并让它与原始图片相同rn Point newPoint = new Point(DownPoint.X, DownPoint.Y);//获取鼠标的坐标rn Graphics g = Graphics.FromImage(destBmp);//在刚才新建的图片上新建一个画板rn Pen p = new Pen(Color.Blue,1);rn int width = Math.Abs(e.X - DownPoint.X), height = Math.Abs(e.Y - DownPoint.Y);//获取矩形的长和宽rn if (e.X < DownPoint.X)rn rn newPoint.X = e.X;rn rn if (e.Y < DownPoint.Y)rn rn newPoint.Y = e.Y;rn rn CatchRect = new Rectangle(newPoint,new Size(width,height));//保存矩形rn g.DrawRectangle(p,CatchRect);//将矩形画在这个画板上rn g.Dispose();//释放目前的这个画板rn p.Dispose();rn Graphics g1 = this.CreateGraphics();//重新新建一个Graphics类rn //如果之前那个画板不释放,而直接g=this.CreateGraphics()这样的话无法释放掉第一次创建的g,因为只是把地址转到新的g了.如同string一样rn g1 = this.CreateGraphics();//在整个全屏窗体上新建画板rn g1.DrawImage(destBmp,new Point(0,0));//将刚才所画的图片画到这个窗体上rn //这个也可以属于二次缓冲技术,如果直接将矩形画在窗体上,会造成图片抖动并且会有无数个矩形.rn g1.Dispose();rn destBmp.Dispose();//要及时释放,不然内存将会被大量消耗rn rn rn rnrn private void Catch_MouseUp(object sender, MouseEventArgs e)rn rn if (e.Button == MouseButtons.Left)rn rn if (CatchStart)rn rn CatchStart = false;rn CatchFinished = true;rn rn rn rn rnrn //鼠标双击事件,如果鼠标位于矩形内,则将矩形内的图片保存到剪贴板中rn private void Catch_MouseDoubleClick(object sender, MouseEventArgs e)rn rn if (e.Button == MouseButtons.Left&&CatchFinished)rn rn if (CatchRect.Contains(new Point(e.X, e.Y)))rn rn Bitmap CatchedBmp = new Bitmap(CatchRect.Width, CatchRect.Height);//新建一个于矩形等大的空白图片rn Graphics g = Graphics.FromImage(CatchedBmp);rn g.DrawImage(originBmp, new Rectangle(0, 0, CatchRect.Width, CatchRect.Height), CatchRect, GraphicsUnit.Pixel);rn //把orginBmp中的指定部分按照指定大小画在画板上rn Clipboard.SetImage(CatchedBmp);//将图片保存到剪贴板rn g.Dispose();rn CatchFinished = false;rn this.BackgroundImage = originBmp;rn CatchedBmp.Dispose();rn this.DialogResult = DialogResult.OK;rn this.Close();rn rn rn rn rnrn  C.创建了Catch窗体后,我们在截图按钮(位于聊天窗体上)上加入以下事件:rn private void bCatch_Click(object sender, EventArgs e)rn rnrn if (bCatch_HideCurrent.Checked)rn rn this.Hide();//隐藏当前窗体rn Thread.Sleep(50);//让线程睡眠一段时间,窗体消失需要一点时间rn Catch CatchForm = new Catch();rn Bitmap CatchBmp = new Bitmap(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height);//新建一个和屏幕大小相同的图片 rn Graphics g = Graphics.FromImage(CatchBmp);rn g.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height));//保存全屏图片rn CatchForm.BackgroundImage = CatchBmp;//将Catch窗体的背景设为全屏时的图片rn if (CatchForm.ShowDialog() == DialogResult.OK)rn //如果Catch窗体结束,就将剪贴板中的图片放到信息发送框中rn IDataObject iData = Clipboard.GetDataObject();rn DataFormats.Format myFormat = DataFormats.GetFormat(DataFormats.Bitmap);rn if (iData.GetDataPresent(DataFormats.Bitmap))rn rn richtextbox1.Paste(myFormat);rn Clipboard.Clear();//清除剪贴板中的对象rn rn this.Show();//重新显示窗体rn rn rnrn rn
这样的正则表达式该如何写?(%xxx%)(%xxx%)(%xxx%)
xxx为任意长度的数字或字母的组合
<%=XXX%>和<%#XXX%>有什么区别?
asp.net的这两个东东是怎么实现的?
Tomcat 问题: Cannot serialize session attribute XXX for
1.网上有两种方法:一种是改sever.xmlrnrnrnrn我试过不行,启动之后,这一部分又没有了rn2.把for后面的类implements 序列化的类rn3.我试了两种方法还是不行,rn在日志里还是会出现这种错误rn问:那位大侠能想到解决方法rn
python反编译xxx
python反编译 python反编译 moons 电机测试软件串口通讯 调试 python反编译
The value for the useBean class attribute XXX is invalid.
这种错误调试了半天都没有调试出来,请教高手啊!BeanTest.jsp文件如下:rn[code=java]rn rn rn My JSP 'BeanTest.jsp' starting pagern rn rn rn rn rn rn rn 刚刚赋值的消息是:rn rn rn[/code]rnrnSimpleBean类:rn[code=java]package com.book.web3;rnrnpublic class SimpleBean rn //属性定义rn private String message="No message specified";rn //属性的getter/setter方法rn public String getMessage()rn return (message);rn rn public void setMessage(String message)rn this.message=message;rn rnrn[/code]
UDP使用sendto(socketSend,xxx,xxx,xxx,xxx,xxx)使用的发送端口是?
RT,UDP使用sendto时,用于发送封包的端口是完全随机的?rn有没什么规律或者范围?rnrn另外,每次要发送封包都新建一个socket,发完就关闭,代价会不会很大?
报错AttributeError: 'QWidget' object has no attribute 'setCentralWidget'如何解决
# -*- coding: utf-8 -*-rnrn# Form implementation generated from reading ui file 'sign.ui'rn#rn# Created: Sun Nov 13 17:09:05 2016rn# by: PyQt4 UI code generator 4.11.3rn#rn# WARNING! All changes made in this file will be lost!rnrnimport sysrnfrom PyQt4 import QtCore, QtGuirnrntry:rn _fromUtf8 = QtCore.QString.fromUtf8rnexcept AttributeError:rn def _fromUtf8(s):rn return srnrntry:rn _encoding = QtGui.QApplication.UnicodeUTF8rn def _translate(context, text, disambig):rn return QtGui.QApplication.translate(context, text, disambig, _encoding)rnexcept AttributeError:rn def _translate(context, text, disambig):rn return QtGui.QApplication.translate(context, text, disambig)rnrnclass Ui_MainWindow(object):rn def setupUi(self, MainWindow):rn MainWindow.setObjectName(_fromUtf8("MainWindow"))rn MainWindow.resize(747, 564)rn self.centralwidget = QtGui.QWidget(MainWindow)rn self.centralwidget.setObjectName(_fromUtf8("centralwidget"))rn self.label = QtGui.QLabel(self.centralwidget)rn self.label.setGeometry(QtCore.QRect(50, 30, 211, 61))rn self.label.setStyleSheet(_fromUtf8("\n"rn"font: 75 22pt \"Microsoft YaHei UI\";"))rn self.label.setObjectName(_fromUtf8("label"))rn self.label_2 = QtGui.QLabel(self.centralwidget)rn self.label_2.setGeometry(QtCore.QRect(50, 120, 81, 18))rn self.label_2.setStyleSheet(_fromUtf8("font: 9pt \"Microsoft YaHei UI\";"))rn self.label_2.setObjectName(_fromUtf8("label_2"))rn self.lineEdit = QtGui.QLineEdit(self.centralwidget)rn self.lineEdit.setGeometry(QtCore.QRect(50, 150, 331, 25))rn self.lineEdit.setObjectName(_fromUtf8("lineEdit"))rn self.label_3 = QtGui.QLabel(self.centralwidget)rn self.label_3.setGeometry(QtCore.QRect(50, 200, 81, 18))rn self.label_3.setStyleSheet(_fromUtf8("font: 9pt \"Microsoft YaHei UI\";"))rn self.label_3.setObjectName(_fromUtf8("label_3"))rn self.lineEdit_2 = QtGui.QLineEdit(self.centralwidget)rn self.lineEdit_2.setGeometry(QtCore.QRect(50, 230, 331, 25))rn self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2"))rn self.label_4 = QtGui.QLabel(self.centralwidget)rn self.label_4.setGeometry(QtCore.QRect(50, 280, 81, 18))rn self.label_4.setStyleSheet(_fromUtf8("font: 9pt \"Microsoft YaHei UI\";"))rn self.label_4.setObjectName(_fromUtf8("label_4"))rn self.lineEdit_3 = QtGui.QLineEdit(self.centralwidget)rn self.lineEdit_3.setGeometry(QtCore.QRect(50, 310, 331, 25))rn self.lineEdit_3.setObjectName(_fromUtf8("lineEdit_3"))rn self.pushButton = QtGui.QPushButton(self.centralwidget)rn self.pushButton.setGeometry(QtCore.QRect(50, 380, 112, 34))rn self.pushButton.setStyleSheet(_fromUtf8("font: 9pt \"Microsoft YaHei UI\";\n"rn"background-color: rgb(215, 215, 215);"))rn self.pushButton.setObjectName(_fromUtf8("pushButton"))rn MainWindow.setCentralWidget(self.centralwidget)rn self.menubar = QtGui.QMenuBar(MainWindow)rn self.menubar.setGeometry(QtCore.QRect(0, 0, 747, 30))rn self.menubar.setObjectName(_fromUtf8("menubar"))rn MainWindow.setMenuBar(self.menubar)rn self.statusbar = QtGui.QStatusBar(MainWindow)rn self.statusbar.setObjectName(_fromUtf8("statusbar"))rn MainWindow.setStatusBar(self.statusbar)rnrn self.retranslateUi(MainWindow)rn QtCore.QMetaObject.connectSlotsByName(MainWindow)rnrn def retranslateUi(self, MainWindow):rn MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))rn self.label.setText(_translate("MainWindow", "欢迎注册", None))rn self.label_2.setText(_translate("MainWindow", "名字", None))rn self.label_3.setText(_translate("MainWindow", "密码", None))rn self.label_4.setText(_translate("MainWindow", "重复密码", None))rn self.pushButton.setText(_translate("MainWindow", "注册", None))rnrnif __name__ == "__main__":rn app = QtGui.QApplication(sys.argv)rn Form = QtGui.QWidget()rn ui = Ui_MainWindow()rn ui.setupUi(Form)rn Form.show()rn sys.exit(app.exec_())rnrnPython菜鸟,想简单实现一个用户注册注册界面,还没有与数据库进行连接,运行时报错rnTraceback (most recent call last):rn File "D:/PyCharm 2016.2.3/example/Sign.py", line 88, in rn ui.setupUi(Form)rn File "D:/PyCharm 2016.2.3/example/Sign.py", line 64, in setupUirn MainWindow.setCentralWidget(self.centralwidget)rnAttributeError: 'QWidget' object has no attribute 'setCentralWidget'rnrn求大神告知解决办法。rnrnrn
学习doc2vec的时候报错:AttributeError: 'str' object has no attribute 'words'
菜鸟一枚,研究了两天实在是不知道怎么解决,请教各位大神!rnrn我用的是Python2.7.10,gensim版本是0.12.2,目前在学习doc2vec模型。rn我在看官方教程(http://radimrehurek.com/gensim/models/doc2vec.html)的时候,一开始就过不了了,教程说:rnrnMake sure you have a C compiler before installing gensim, to use optimized (compiled) doc2vec training (70x speedup [blog]).rnrnInitialize a model with e.g.:rnrn>>> model = Doc2Vec(documents, size=100, window=8, min_count=5, workers=4)rnPersist a model to disk with:rnrn>>> model.save(fname)rn>>> model = Doc2Vec.load(fname) # you can continue training with the loaded model!rnThe model can also be instantiated from an existing file on disk in the word2vec C format:rnrn>>> model = Doc2Vec.load_word2vec_format('/tmp/vectors.txt', binary=False) # C text formatrn>>> model = Doc2Vec.load_word2vec_format('/tmp/vectors.bin', binary=True) # C binary formatrnrnrn我的代码如下,其中negForPy.txt大概长这样:rn[code=text]rn标准间太差 房间还不如3星的 而且设施非常陈旧.建议酒店把老的标准间从新改善.rn服务态度极其差,前台接待好象没有受过培训,连基本的礼貌都不懂,竟然同时接待几个客人;大堂副理更差,跟客人辩解个没完,要总经理的电话投诉竟然都不敢给。要是没有作什么亏心事情,跟本不用这么怕。rn地理位置还不错,到哪里都比较方便,但是服务不象是豪生集团管理的,比较差。下午睡了一觉并洗了一个澡,本来想让酒店再来打扫一下,所以,打开了,请打扫的服务灯,可是到晚上回酒店,发现打扫得服务灯被关掉了,而房间还是没有打扫过。rn1。我住的是靠马路的标准间。房间内设施简陋,并且的房间玻璃窗户外还有一层幕墙玻璃,而且不能打开,导致房间不能自然通风,采光不好。2。吃了三顿早餐,品种少得可怜。3。二楼餐厅被租出去了,价格特贵。原来订餐时告之房客可以打九折(房间服务指南里也明明白白写的,等到结帐时却告之海鲜和酒水是不能打折的,而且没有发票,找来经理才好不容易在第二天拿到发票。综合来说与四星级差距太大了!rn1。我住的是靠马路的标准间。房间内设施简陋,并且的房间玻璃窗户外还有一层幕墙玻璃,而且不能打开,导致房间不能自然通风,采光不好。2。吃了三顿早餐,品种少得可怜。3。二楼餐厅被租出去了,价格特贵。原来订餐时告之房客可以打九折(房间服务指南里也明明白白写的,等到结帐时却告之海鲜和酒水是不能打折的,而且没有发票,找来经理才好不容易在第二天拿到发票。综合来说与四星级差距太大了!rn[/code]rnrn[code=python]rn#encoding: utf-8rnfrom gensim.models.doc2vec import Doc2Vecrnrnwith open('negForPy.txt','r') as infile:rn documents = infile.readlines()rnmodel =Doc2Vec(documents,size=100,window=8,min_count=5,workers=4)rnrnmodel = Doc2Vec.load_word2vec_format('vectors1.txt', binary = False)[/code]rnrn第8行和之前的代码是不同的两种方法,我分开运行不管哪种方法都会报错,比如就像上面那样的代码直接运行,报错是:rnTraceback (most recent call last):rn File "E:\zzWorkFiles\ZZworkspace\Practise1\src\Prac1\draft2.py", line 6, in rn model =Doc2Vec(["aaaa","andajfiaihe","dfghiah","adoifjeng"],size=100,window=8,min_count=5,workers=4)rn File "D:\programFiles\Python2.7.10\lib\site-packages\gensim-0.12.2-py2.7-win32.egg\gensim\models\doc2vec.py", line 584, in __init__rn self.build_vocab(documents, trim_rule=trim_rule)rn File "D:\programFiles\Python2.7.10\lib\site-packages\gensim-0.12.2-py2.7-win32.egg\gensim\models\word2vec.py", line 495, in build_vocabrn self.scan_vocab(sentences, trim_rule=trim_rule) # initial surveyrn File "D:\programFiles\Python2.7.10\lib\site-packages\gensim-0.12.2-py2.7-win32.egg\gensim\models\doc2vec.py", line 627, in scan_vocabrn document_length = len(document.words)rnAttributeError: 'str' object has no attribute 'words'rnrnrn这种情况下应该怎么解决处理呢??rn跪求大神解答!rn
console下 ./xxx 和 xxx 有什么区别?
rt
jQuery报错 Object [object Object] has no method
我想在首页banner上加个轮播效果 在网上下载了个效果,然后放进去结果报错 Object [object Object] has no method 'slide'rn这是jQuery调用[code=javascript]rn $(function()rn $("#slide").slide(rn affect:4,rn time:3000,rn speed:400,rn dot_text:true,rn );rn );[/code]rn这是jQuery代码rn[code=javascript] rn(function($)rn $.fn.slide=function(options)rn var defaults= rn affect:4, //1:上下滚动; 2:幕布式; 3:左右滚动;4:淡入淡出rn time: 4000, //间隔时间rn speed:500, //动画快慢rn dot_text:true,//按钮上有无序列号rn ;rn var opts=$.extend(defaults,options);rn var $this=$(this);rn var ool=$(" ");rn var $box=$this.find("ul");rn var $li=$box.find("li");rn var timer=null;rn var num=0;rn rn $this.append(ool);rn $box.find("li").each(function(i)rn ool.find("p").append($(""));rn if(opts.dot_text)rn ool.find("b").eq(i).html(i+1)rn rn )rn ool.find("b").eq(0).addClass("cur");rn switch(opts.affect)rn case 1:rn break;rn case 2:rn $box.find("li").css("display","none");rn break;rn case 3:rn $box.css("width":$li.eq(0).width()*$li.length);rn $li.css("float","left");rn break;rn case 4:rn $box.find("li").css("display","none");rn break;rn rn $box.find("li").eq(0).show(0);rn ool.find("b").mouseover(function() rn num=$(this).index();rn run ();rn )rn timer=setInterval(auto,opts.time);rn function auto()rn num<$box.find("li").length-1?num++:num=0;rn run();rn rn function run()rn ool.find("b").eq(num).addClass("cur").siblings().removeClass("cur");rn switch(opts.affect)rn case 1:rn $box.stop(true,false).animate("top":-240*num,opts.speed);rn break;rn case 2:rn $box.find("li").css("position":"absolute");rn $box.find("li").stop(false,true).fadeOut(opts.speed).eq(num).slideDown(opts.speed);rn break;rn case 3:rn $box.stop(true,false).animate("left":-670*num,opts.speed);rn break; rn case 4:rn $box.find("li").css("position":"absolute");rn $box.find("li").stop(false,true).fadeOut(opts.speed).eq(num).fadeIn(opts.speed);rn break; rn rn rn $this.mouseover(function()rn clearInterval(timer); rn )rn $this.mouseout(function()rn timer=setInterval(auto,opts.time); rn )rnrn)(jQuery) [/code]rn这是HTML[code=html] rn rn Execute("SELECT * FROM `#@__gallery` WHERE (`classid`='$cid' or `parentstr` LIKE '%$cid%') AND `delstate`='' AND `flag` like '%f%' ORDER BY `orderid` DESC");rn rn while($row = $dosql->GetArray())rn rn ?>rn rn rn rn rn rn [/code]rn现在情况是图片不动。。。请问到底是什么情况?
pexpect调用ssh的报错:'NoneType' object has no attribute 'expect'
本人初学python,是菜鸟中的菜鸟。今天跑了一个脚本,调用pexpect连接ssh到远端服务器运行命令并返回结果。python版本是2.5.rn遇到报错,无法解决。望DX赐教。谢谢!rnrn错误信息(斜体字部分是脚本中定义的部分信息):rn[i]ERROR! 1rnSSH could not login. Here is what SSH said:[/i]rnPassword: rn'NoneType' object has no attribute 'expect'rnrn这个报错是说对象未定义类型?错误应该是发生在第一个if i==0处,但是child已经是由pexpect.spawn生成的对象了,为什么要报错说NoneType?rnrnrnrn完整脚本:(来源: http://www.oschina.net/question/12_7583 )rnrn#!/usr/bin/env pythonrnimport pexpectrnimport getpass, osrnrndef ssh_command(user, host, password, command):rn ssh_newkey="Are you sure you want to continue connecting"rn child = pexpect.spawn ('ssh -l %s %s %s'%(user, host, command))rn i=child.expect([pexpect.TIMEOUT, ssh_newkey, 'passowrd: '])rn if i==0:rn print 'ERROR! 1'rn print 'SSH could not login. Here is what SSH said:'rn print child.before, child.afterrn return Nonern if i==1:rn child.sendline('yes')rn child.expect('password: ')rn i=child.expect([pexpect.TIMEOUT, 'password: '])rn if i==0:rn print 'ERROR! 2'rn print 'SSH could not login. here is what SSH said:'rn print child.before, child.afterrn return Nonern child.sendline(password)rn return childrnrndef main():rn host = raw_input('Hostname: ')rn user = raw_input('User: ')rn password = getpass.getpass()rn command = raw_input('Enter the command: ')rn child = ssh_command(user, host, password, command)rn child.expect(pexpect.EOF)rn print child.beforernrnif __name__ == '__main__':rn try:rn main()rn except Exception, e:rn print str(e)rn# traceback.print_exc()rn os._exit(1)rnrn
互联网+ 与智能xxx、智慧xxx
互联网+ 与智能xxx、智慧xxx 太阳火神的美丽人生 (http://blog.csdn.net/opengl_es) 本文遵循“署名-非商业用途-保持一致”创作公用协议 转载请保留此句:太阳火神的美丽人生 - 本博客专注于敏捷开发及移动和物联设备研究:iOS、Android、Html5、Arduino、pcDuino,否则,出自本博客的文章拒绝...
Spring的classpath*:xxx\xxx\bean.xml
如题. classpath*: rn这个*号代表什么意思?
执行python代码报错(AttributeError: 'NoneType' object has no attribute 'magic')
执行python代码报错,在网上查了很久,都没有查到解决办法,请大神指导一下!谢谢!rnrn[root@master dataannl]# python -VrnPython 3.6.2rn[root@master dataannl]# rn[root@master dataannl]# rn[root@master dataannl]# cat example01.pyrn# -*- coding: utf-8 -*-rnrn# from pandas import Series,DataFramern# import pandas as pdrnrnfrom IPython import get_ipythonrnimport matplotlib.pyplot as pltrnget_ipython().magic(u'matplotlib inline')rnrnplt.ylabel('True Positive Rate') #坐标轴标签rnplt.ylim(0,1.05) #边界范围rnplt.xlim(0,1.05) #边界范围rnplt.legend(loc=4) #图例rnplt.show() #显示作图结果rnrn[root@master dataannl]# rn[root@master dataannl]# python example01.pyrnTraceback (most recent call last):rn File "example01.py", line 8, in rn get_ipython().magic(u'matplotlib inline')rnAttributeError: 'NoneType' object has no attribute 'magic'rn[root@master dataannl]#
python代码报错(AttributeError: 'NoneType' object has no attribute 'run_line_magic')
import pandas as pdrnimport matplotlib.pyplot as plt,matplotlib.image as mpimgrnfrom sklearn.model_selection import train_test_splitrnfrom sklearn import svmrn[b]#~matplotlib inlinernfrom IPython import get_ipythonrnget_ipython().run_line_magic('matplotlib','iinline')[/b][color=#FF0000][/color]rnrnimport matlpotlibrnrnlabeled_images = pd.read_csv('D:/kaggle/train.csv')rnimages = labeled_images.iloc[0:5000,1:]rnlabels = labeled_images.iloc[0:5000,:1]rntrain_images,test_images,train_labels,test_labels = train_test_split(rn images,labels,train_size=0.8)rn rni=1rnimg = train_images.iloc[i].as_matrix()rnimg = img.reshape((28,28))rnplt.imshow(img,cmap='gray')rnplt.title(train_labels.iloc[i,0])rn主要是我想画图,如下[img=https://img-bbs.csdn.net/upload/201712/06/1512547153_833788.png][/img]rn[b]%matlpotlib inline会报错 invalid syntax,上网搜了下用ipython里的run_line_magic也不行[/b]所以想来问下大家rnrn小白的软件配置是:python3.6 和Geany
AttributeError: '_NamespacePath' object has no attribute 'sort'
python3.6安装six包报错,报错信息为:AttributeError: '_NamespacePath' object has no attribute 'sort'rn执行pip list命令也报同样的错。rn环境为64位windows 10,已安装anaconda3rn求大神指导,谢谢![img=https://img-bbs.csdn.net/upload/201705/16/1494935625_44723.png][/img]
一直`class`has no member named`XXX`
如題rnrn程式是從別人那邊拿過來的rn確定原本可以正確運行rnrn但在我自己的電腦上面跑就出錯rnrn像是其中一個class:rnrnrnclass msb_tree rn bool **bitPlane; //Bits, from top to low [0~tree_depth]rn int *width, *height;rn int tree_depth;rn rnpublic:rn rn msb_tree(int baseWidth, int baseHeight);rn rn ~msb_tree();rnrn void build() rn bool tmp[4]=false,false,false,false;rn int x, y, i, j, k;rn for(i=tree_depth-2;i > -1;i--) rnrn for(y=0;y
Unfortunately,Xxx has stoppe 这是我的logcat
07-15 02:03:35.355: I/Process(1664): Sending signal. PID: 1664 SIG: 9n07-15 02:03:36.955: D/AndroidRuntime(1703): Shutting down VMn07-15 02:03:36.955: W/dalvikvm(1703): threadid=1: thread exiting with uncaught exception (group=0xb1a8fba8)n07-15 02:03:36.995: E/AndroidRuntime(1703): FATAL EXCEPTION: mainn07-15 02:03:36.995: E/AndroidRuntime(1703): Process: com.example.android_notification, PID: 1703n07-15 02:03:36.995: E/AndroidRuntime(1703): java.lang.RuntimeException: Unable to start activity ComponentInfocom.example.android_notification/com.example.android_notification.MainActivity: java.lang.NullPointerExceptionn07-15 02:03:36.995: E/AndroidRuntime(1703): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)n07-15 02:03:36.995: E/AndroidRuntime(1703): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)n07-15 02:03:36.995: E/AndroidRuntime(1703): at android.app.ActivityThread.access$800(ActivityThread.java:135)n07-15 02:03:36.995: E/AndroidRuntime(1703): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)n07-15 02:03:36.995: E/AndroidRuntime(1703): at android.os.Handler.dispatchMessage(Handler.java:102)n07-15 02:03:36.995: E/AndroidRuntime(1703): at android.os.Looper.loop(Looper.java:136)n07-15 02:03:36.995: E/AndroidRuntime(1703): at android.app.ActivityThread.main(ActivityThread.java:5017)n07-15 02:03:36.995: E/AndroidRuntime(1703): at java.lang.reflect.Method.invokeNative(Native Method)n07-15 02:03:36.995: E/AndroidRuntime(1703): at java.lang.reflect.Method.invoke(Method.java:515)n07-15 02:03:36.995: E/AndroidRuntime(1703): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)n07-15 02:03:36.995: E/AndroidRuntime(1703): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)n07-15 02:03:36.995: E/AndroidRuntime(1703): at dalvik.system.NativeStart.main(Native Method)n07-15 02:03:36.995: E/AndroidRuntime(1703): Caused by: java.lang.NullPointerExceptionn07-15 02:03:36.995: E/AndroidRuntime(1703): at com.example.android_notification.MainActivity.onCreate(MainActivity.java:29)n07-15 02:03:36.995: E/AndroidRuntime(1703): at android.app.Activity.performCreate(Activity.java:5231)n07-15 02:03:36.995: E/AndroidRuntime(1703): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)n07-15 02:03:36.995: E/AndroidRuntime(1703): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)n07-15 02:03:36.995: E/AndroidRuntime(1703): ... 11 moren07-15 02:03:40.435: I/Process(1703): Sending signal. PID: 1703 SIG: 9n
Unfortunately,xxx has stopped.” 求解决
[code=text]rnrnrnrn rnrn rn rn rn rnrn rn rn rn rn rn rn rn rnrnrn[/code]rn[img=https://img-bbs.csdn.net/upload/201507/02/1435814527_952612.png][/img][img=https://img-bbs.csdn.net/upload/201507/02/1435814540_322822.png][/img]
相关热词 c# 线程结束时执行 c# kb mb 图片 c# 替换第几位字符 c#项目决定成败 c# 与matlab c# xml缩进 c#传感器基础 c#操作wps c# md5使用方法 c# 引用父窗口的组件