想要如何拉动"桶#34;来自python中的返回对象的数据。状态是一个包含要显示的数据列表的存储桶。我尝试了几种不同的方法,除了对象参考之外似乎无法显示任何内容。基本上,在这个"桶中显示此类数据的最佳方式是什么?或数据列表。 ":type:list [ObjectedCreatedName]"
func parseData() {
fetchedExercise.removeAll()
let url = URL(string: urlPath)!
let task = URLSession.shared.dataTask(with: url) { (data, response, error) in
if error != nil {
print("Error while parsing JSON")
}
else {
do {
if let data = data,
let fetchedData = try JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? [String:Any],
let exercises = fetchedData["results"] as? [[String: Any]] {
for eachExercise in exercises {
if eachExercise["license_author"] as! String == "wger.de" {
let name = eachExercise["name"] as! String
let description = eachExercise["description"] as! String
let id = eachExercise["id"] as! Int
}
答案 0 :(得分:1)
你可以:
action
e.g:
def print_sequence(sequence):
seq_type = sequence.__class__.__name__
elem_type = sequence[0].__class__.__name__ if len(sequence) > 0 else ''
print('{}[{}]'.format(seq_type, elem_type))