标签: attributeerror

sram客户端与paramiko(python)

# sshpy v1 by s0urd
# simple ssh client 
# irc.gonullyourself.org 6667 #code

import paramiko
import os

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
privatekey = os.path.expanduser('/home/rabia/private')
mkey = paramiko.RSAKey.from_private_key_file(privatekey)
ssh.connect('78.46.172.47', port=22, username='s0urd', password=None, pkey=mkey)

while True:
      pick = raw_input("sshpy: ")
      stdin, stdout, stderr = ssh.exec_command(pick)
      print stdout.readlines()   
      ssh.close()
Run Code Online (Sandbox Code Playgroud)

当我尝试运行超过1个命令时,我收到此错误:

AttributeError: 'NoneType' object has no attribute 'open_session'

python ssh paramiko attributeerror

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

AttributeError:'int'对象没有属性'insert'

救命!当我让一件事情起作用时,其他事情却不起作用!再次,我相信经验丰富的眼睛很简单,但是我很挣扎!这是我生成清单和清单数据的代码。

#Frame Creation


allframes = []

for n in range (0, (workingframes*archnodes*3)):
    allframes.append(n)

frames = allframes

print frames



#Frame Population

for f in range (0, workingframes):

    if f<=(workingframes/2):

        for x in range (0, (archnodes)):
            frames[((archnodes*3)+f)].insert(((archnodes*3)+f), (archstartred[x]))
            frames[((archnodes*3)+f+workingframes)].insert(((archnodes*3)+f+workingframes),(archstartgrn[x]))
            frames[((archnodes*3)+f+workingframes*2)].insert(((archnodes*3)+f+workingframes*2),(archstartblu[x]))

        for y in range (0, nodesperframe):
            archstartred.pop()
            archstartgrn.pop()
            archstartblu.pop()
            archstartred.insert(0, backred)
            archstartgrn.insert(0, backgrn)
            archstartblu.insert(0, backblu)

    else:
        for y in range (0, nodesperframe):
            archstartred.pop(0)
            archstartgrn.pop(0)
            archstartblu.pop(0)
            archstartred.append(backred)
            archstartgrn.append(backgrn)
            archstartblu.append(backblu)

        for x in range (0, (archnodes)):
            frames[(archnodes*3)+f].insert((archnodes*3), (archstartred[x]))
            frames[(archnodes*3)+f+workingframes].insert(((archnodes*3)+1),(archstartgrn[x]))
            frames[(archnodes*3)+f+workingframes*2].insert(((archnodes*3)+2),(archstartblu[x]))
Run Code Online (Sandbox Code Playgroud)

我不断收到这个可爱的错误:

AttributeError: 'int' object …
Run Code Online (Sandbox Code Playgroud)

python insert attributeerror

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

python 3无法写入文件

我的代码是:

from random import randrange, choice
from string import ascii_lowercase as lc
from sys import maxsize
from time import ctime

tlds = ('com', 'edu', 'net', 'org', 'gov')

for i in range(randrange(5, 11)):
    dtint = randrange(maxsize)                      
    dtstr = ctime()                                  
    llen = randrange(4, 8)                              
    login = ''.join(choice(lc)for j in range(llen))
    dlen = randrange(llen, 13)                          
    dom = ''.join(choice(lc) for j in range(dlen))
    print('%s::%s@%s.%s::%d-%d-%d' % (dtstr, login,dom, choice(tlds),
                                  dtint, llen, dlen), file='redata.txt')
Run Code Online (Sandbox Code Playgroud)

我想在文本文件中打印结果,但是我收到此错误:

dtint, llen, dlen), file='redata.txt')
AttributeError: 'str' object has no attribute 'write'
Run Code Online (Sandbox Code Playgroud)

python file attributeerror python-3.x

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

Matplotlib set_major_formatter AttributeError

我正在尝试使用set_major_formatter在matplotlib图上格式化yaxis。该图已正确生成,但ax.yaxis.set_major_formatter()引发了一些奇怪的错误。

格式化程序:

def mjrFormatter(x):
    return "{0:.0f}%".format(x * 100)
Run Code Online (Sandbox Code Playgroud)

使用格式化程序的代码:

 ...
 ax.yaxis.set_major_formatter(mjrFormatter)
 ...
Run Code Online (Sandbox Code Playgroud)

错误:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-108-b436fe657a8b> in <module>()
----> 1 plot_func(data = data, figsize=(20,10), fig_title = 'title')

<ipython-input-107-d60ffc010a75> in plot_percent_moc(data, figsize, fig_title)
     16         _ = data2[col].plot()
     17 
---> 18     ax.yaxis.set_major_formatter(mjrFormatter)
     19 
     20     fig.suptitle(fig_title, fontsize = 14)

C:\Python27\lib\site-packages\matplotlib\axis.pyc in set_major_formatter(self, formatter)
   1396         self.isDefault_majfmt = False
   1397         self.major.formatter = formatter
-> 1398         formatter.set_axis(self)
   1399 
   1400     def set_minor_formatter(self, formatter):

AttributeError: 'function' object has no attribute 'set_axis'

---------------------------------------------------------------------------
AttributeError …
Run Code Online (Sandbox Code Playgroud)

matplotlib formatter attributeerror

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

Python Thread.start()导致AttributeError

在python中编写客户端 - 服务器系统时,我在服务器标准输出中遇到了一个奇怪的错误,这不应该发生:

Traceback (most recent call last):
  File "C:\Users\Adam\Drive\DJdaemon\Server\main.py", line 33, in <module>
    ClientThread(csock, addr).start()
AttributeError: 'ClientThread' object has no attribute '_initialized'
Run Code Online (Sandbox Code Playgroud)

我将该行分成多行,而start()导致了错误.

有任何想法吗?这是服务器源代码 - 客户端只是打开并关闭连接:

import socket, threading

class ClientThread(threading.Thread):
    def __init__(self, sock, addr):
        self.sock = sock
        self.addr = addr
    def run(self):
        sock = self.sock
        addr = self.addr

        while True:
            msg = sock.recv(1024).decode()
            if not msg:
                print('Disconnect: ' + addr[0] + ':' + str(addr[1]))
                sock.close()
                return

# Constants
SERVER_ADDRESS = ('', 25566)
MAX_CLIENTS = 10
MCSRV_ADDRESS = ('localhost', …
Run Code Online (Sandbox Code Playgroud)

python multithreading attributeerror

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

我如何在python中发送电子邮件?此代码无效

import smtplib
#SERVER = "localhost"

FROM = 'monty@python.com'

TO = ["jon@mycompany.com"] # must be a list

SUBJECT = "Hello!"

TEXT = "This message was sent with Python's smtplib."

# Prepare actual message

message = """\
From: %s
To: %s
Subject: %s

%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)

# Send the mail

server = smtplib.SMTP('myserver')
server.sendmail(FROM, TO, message)
server.quit()
Run Code Online (Sandbox Code Playgroud)

当我尝试在终端中的python shell中运行它时,它给了我这个错误:

Traceback (most recent call last):
    File "email.py", line 1, in <module>
        import smtplib
    File "/usr/lib/python2.7/smtplib.py", line 46, in …
Run Code Online (Sandbox Code Playgroud)

python email smtp attributeerror python-2.7

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

尝试在pyusb中调用后端模块时出错。“ AttributeError:'模块'对象没有属性'后端'”

我最近为此项目安装了pyusb,该项目试图尝试写入USB LED留言板并收到以下错误:

AttributeError: 'module' object has no attribute 'backend'

我不知道为什么,我检查了pyusb模块文件,它显然有一个名为“ backend”的文件夹,并且里面有正确的文件。

这是我所有的代码:

import usb.core
import usb.util
import sys

backend = usb.backend.libusb01.get_backend(find_library=lambda C: "Users\nabakin\Desktop\libusb-win32-bin-1.2.6.0\lib\msvc_x64")

#LED Display Message device identify
MessageDevice = usb.core.find(idVendor=0x1D34, idProduct=0x0013, backend=backend)

if MessageDevice is None:
    raise ValueError('LED Message Display Device could not be found.')

MessageDevice.set_configuration()





# get an endpoint instance
cfg = MessageDevice.get_active_configuration()
interface_number = cfg[(0,0)].bInterfaceNumber
print interface_number
alternate_settting = usb.control.get_interface(interface_number)
intf = usb.util.find_descriptor(
    cfg, bInterfaceNumber = interface_number,
    bAlternateSetting = alternate_setting
)

ep = usb.util.find_descriptor(
    intf, …
Run Code Online (Sandbox Code Playgroud)

python module attributeerror python-2.7 pyusb

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

AttributeError:'Series'对象没有属性'items'

我正在尝试使用同事写的脚本.

这部分脚本工作正常:

xl = pd.ExcelFile(path + WQ_file)
sheet_names = xl.sheet_names

df = pd.read_excel(path + WQ_file, sheetname = 'Chemistry Output Table', skiprows = [0,1,2,4,5,6,7], 
               index_col = [0,1], na_values = ['', 'na', '-'])
df.index.names = ['Field_ID', 'Date_Time']

header = pd.read_excel(path + WQ_file, sheetname = 'header data',  
               index_col = [0], na_values = ['', 'na', ' - '])
header_dict = {ah: header['name_short'].loc[ah] for ah in header.index}

analytes_excel = pd.read_excel(path + WQ_file, sheetname = 'analytes', columns = 'name')
analytes_list = [item for sublist in analytes_excel.values.tolist() …
Run Code Online (Sandbox Code Playgroud)

python series attributeerror python-2.7 pandas

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

Python CSV阅读器TypeError:字节对象上的字符串模式

我想第一次使用python CSV阅读器.我有一个方法要求用户选择他们想要解析的文件,然后它将该文件路径传递给parse方法:

def parse(filename):
        parsedFile = []
        with open(filename, 'rb') as csvfile:
                dialect = csv.Sniffer().sniff(csvfile.read(), delimiters=';,|')
                csvfile.seek(0)
                reader = csv.reader(csvfile, dialect)

                for line in reader:
                    parsedFile.append(line)
                return(parsedFile)

def selectFile():
        print('start selectFile method')
        localPath = os.getcwd() + '\Files'
        print(localPath)
        for fileA in os.listdir(localPath):
                print (fileA)

        test = False
        while test == False:
                fileB = input('which file would you like to DeID? \n')
                conjoinedPath = os.path.join(localPath, fileB)
                test = os.path.isfile(conjoinedPath)


        userInput = input('Please enter the number corresponding to which client ' + …
Run Code Online (Sandbox Code Playgroud)

python csv attributeerror python-3.x

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

Python:为什么我收到AttributeError:__enter__

我没有重新分配open关键字,但仍然收到此错误。有任何建议或指导来纠正我的错误吗?

 with tempfile.mkdtemp() as test_dir:
        print(test_dir)
Run Code Online (Sandbox Code Playgroud)

AttributeError: __enter__

我也是python的新手,我很难理解这些概念。

python temporary-directory attributeerror contextmanager

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