擅长:python、mysql、java
<p>试试这个:</p>
<pre><code># initial list
mystring = [ "Tiger Nixon, System Architect, Edinburgh, 5421, 2011/04/25", "Garrett Winters, Accountant, Tokyo, 422, 2011/07/25" ]
# empty list to store new values
array = []
# loop through the list and split each value
for i in mystring:
array.append(i.split(",")) # splits into list and appends it a new list
print(array) # prints the resultant array
</code></pre>
<p>您也可以使用下面的一行列表理解方法。你知道吗</p>
<pre><code>mystring = [string.split(",") for string in mystring]
</code></pre>
<p>输出:</p>
<pre><code>[['Tiger Nixon', ' System Architect', ' Edinburgh', ' 5421', ' 2011/04/25'], ['Garrett Winters', ' Accountant', ' Tokyo', ' 422', ' 2011/07/25']]
</code></pre>
<p>请参阅操作中的代码<a href="https://repl.it/repls/EmbarrassedDramaticLocus" rel="nofollow noreferrer">here</a>。你知道吗</p>