本问题已经有最佳答案,请猛点这里访问。
我是python新手。我试图将一串字符串存储到一个数组中,并在最后打印出这个数组,但是它打印出来的却是一长串字符。这是我的代码:
1 2 3 4 5 6 | user_with_no_records = [""] for user_test_docs in json_data['results']: ... do something here ... user_with_no_records.extend(user_test_docs['userId'].replace("'", '"')) ... pprint(user_with_no_records) |
而不是打印出来:
1 | "1234-4a20-47c0-b23c-a35a","53dd-4120-4249-b4f6-ebe2" |
它打印出
1 | "1","2","3","4","-","a","2","0".... |
1 2 3 | >>> b = 'Hello' >>> list(b) ['H', 'e', 'l', 'l', 'o'] |
相反,您显然希望执行