小编임종훈*_*임종훈的帖子

情节:类型错误:无法将字典更新序列元素#0 转换为序列

我目前正在处理的项目有问题,所以我留下了一个问题。
当前内容由传感器以表格形式绘制。但是前几天,当我在做某事时,我不知道如何解决它,所以我寻求帮助。

import plotly.plotly as py
import plotly.figure_factory as ff
from bluepy import sensortag
import sys
import time
import datetime
import numpy as np

py.sign_in("smrlswja9963","94b4enXKYqyOu4iuPDGG")

time.sleep(1.0)

tag = sensortag.SensorTag('24:71:89:CC:53:00')
tag.IRtemperature.enable()
tag.humidity.enable()

stream1=py.Stream('liz9v2c0or')
stream1.open()

i=0     
while True:
    now = datetime.datetime.now()
    dateTime = now.strftime("%Y-%m-%d %H:%M:%S")

    A = tag.IRtemperature.read()
    B = tag.humidity.read()
    tempt=A[0]
    humty=B[0]

    stream1.write({dateTime,tempt,humty})

    i+=1

    tag.waitForNotifications(3.0)     

table = go.Table(
    header=dict(values=["dateTime","tempt","humty"]),
    cells=dict(values=[[dateTime],[tempt],[humty]]),
    stream = dict(token='liz9v2c0or',))

data=[table]
py.iplot(table, filename="latex table")
Run Code Online (Sandbox Code Playgroud)

执行以下代码后,出现如下错误。

Traceback (most recent call last):
  File "/home/pi/do it.py", line 27, in <module>
    stream1.write({dateTime,tempt,humty}) …
Run Code Online (Sandbox Code Playgroud)

python plotly

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

AttributeError:'_io.TextIOWrapper'对象没有属性'next'?

大家。我目前正在努力合并 csv 文件。例如,您有从 filename1 到 filename100 的文件。我使用以下代码合并100个文件,出现以下错误:我先把代码放上来。导入 csv

fout=open("aossut.csv","a")
# first file:
for line in open("filename1.csv"):
    fout.write(line)
# now the rest:    
for num in range(2,101):
    f = open("filename"+str(num)+".csv")
    f.next() # skip the header
    for line in f:
         fout.write(line)
    f.close() # not really needed
fout.close()
Run Code Online (Sandbox Code Playgroud)

并且执行上述文件时出现如下错误:

File "C:/Users/Jangsu/AppData/Local/Programs/Python/Python36-32/tal.py", line 10, in 
<module>
    f.next() # skip the header
AttributeError: '_io.TextIOWrapper' object has no attribute 'next'
Run Code Online (Sandbox Code Playgroud)

我已经研究了几天了,我不知道该怎么办。

python csv

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

标签 统计

python ×2

csv ×1

plotly ×1