您好,这些代码确实请求Steam Web API
val query = s"select count(*) from schema.table"
val connection = getMySqlConnection(...)
val rs = connection.createStatement().executeQuery(query)
rs.next()
val count = rs.getLong(1)
connection.close()
count
这就是它的返回内容:
const request = require("request");
request({
url: "https://api.steampowered.com/IEconService/GetTradeOffers/v1/?key=MYAPIKEY&get_sent_offers=1&active_only=1&format=json",
json: true
}, (err, responser, body) => {
console.log(body.response['trade_offers_sent']);
});
但是当我试图通过这种方式获取accountid_other的价值时:
{
trade_offers_sent: [
{
tradeofferid: '3974708687',
accountid_other: 82613664,
message: 'test message',
expiration_time: 1587017229,
trade_offer_state: 9,
items_to_give: [Array],
is_our_offer: true,
time_created: 1585807629,
time_updated: 1585807629,
from_real_time_trade: false,
escrow_end_date: 0,
confirmation_method: 2
}
]
}
返回未定义
答案 0 :(得分:1)
fpath = 'file.txt'
with open(fpath, 'r+') as f:
lines = f.readlines()
f.seek(0)
f.truncate()
for line in lines:
line = line.replace('https://', '')
f.write(line)
中的方括号[ ... ]
表示它包含一个数组,而不仅仅是一个项目(它恰好是数组中的一个项目)。因此,要获得您感兴趣的价值,您需要指定所需项目的索引或使用循环来遍历它。在这种情况下,您需要第一项,可以使用trade_offers_sent
来获取它。