看看下面的字符串:
E|1256280||2014-01-05 17:54:00|1|2014-01-05 18:59:53|True
我想把它分开.管道符号“|”.因此我使用以下python代码(其中line是包含上述字符串的字符串):
print line
print str(type(line))
print str(line[1])
parts = line.split['|']
print str(parts)
但是,使用这段代码时,我收到以下错误:
E|1256280||2014-01-05 17:54:00|1|2014-01-05 18:59:53|True
|
Traceback (most recent call last):
File "/path/to/my/pythonscritp.py", line 34, in crawl_live_quotes
parts = line.split['|']
TypeError: 'builtin_function_or_method' object is not subscriptable
但是,我不明白我在这里做错了什么.有什么建议?