我試圖使用python將實體存儲到azure存儲表中。但我有以下錯誤。TypeError:insert_or_replace_entity()至多需要4個參數(給出5個)
self.table_service.insert_or_replace_entity('myDataTable', 'A100', keyVal, self.task)
TypeError: insert_or_replace_entity() takes at most 4 arguments (5 given)
我提供4個參數只進insert_or_replace_entity()功能,但是編譯器考慮五,爲什麼呢?我不明白,請有人幫助我。
我的代碼是在這裏:提前
#!/usr/bin/env python
import time
import csv
import sys
from azure.storage.table import TableService, Entity
class Azure:
table_service = ''
task = {}
PartitionKey = ''
RowKey = ''
RPI_ID = ''
PIC_ID = ''
Date = ''
Time = ''
Temp = ''
def openAccount(self):
self.table_service = TableService(account_name='<My account name>', account_key='<My key>')
def createTable(self):
self.table_service.create_table('myDataTable')
def setEntity(self, i):
task_i = Entity()
task_i.PartitionKey = 'A100'
task_i.RowKey = str(i)
print task_i
task_i.RPI_ID = 'A100'
task_i.PIC_ID = 'P100'
task_i.Date = time.strftime("%d-%m-%Y")
task_i.Time = time.strftime("%I:%M")
task_i.Temp = '22.05'
self.task = task_i;
def insertOrReplaceEntity(self, keyVal):
self.table_service.insert_or_replace_entity('myDataTable', 'A100', keyVal, self.task)
data = Azure()
data.openAccount()
data.createTable()
cnt = 0
while (cnt < 10):
data.setEntity(cnt)
data.insertOrReplaceEntity(cnt)
cnt = cnt + 1
time.sleep(1)
感謝。
完美的工作。非常感謝。 – rsp