-1
source_table = raw_input("Enter the table name : ")
PK = raw_input("Enter the primary key : ")
PriKeyData = raw_input("Enter the data type for Primary key int-number, str-string :")
with open('PriSortKeys.csv', 'rb') as csvfile:
csvreader = csv.reader(csvfile, delimiter='\t', quotechar='|')
for row in csvreader:
if PriKeyData == "int":
prikeyvalue = int(row[0])
else:
prikeyvalue = str(row[0])
logger.info("Checking for Key :" + str(prikeyvalue))
## Fetching data from table based on primarykey
sourcetable_data= source_table.query(KeyConditionExpression=Key(PK).eq(prikeyvalue))
我想把主鍵和它的值作爲用戶輸入並試圖查詢,但我得到以下錯誤:我越來越AttributeError:'str'對象在python中沒有屬性'查詢'
'str' object has no attribute 'query'
'source_table = raw_input()'...那總是一個'str' ...你試圖運行query()對什麼對象? –