我试图从我的 SQL 服务器调用单个列,然后将其拆分为每个“,”,因此我有此列中所有字段的列表
我目前有这个代码:
for element in tagall:
parts = element.split(',')
print (parts)
但这会返回
'pyodbc.row has no attribute 'split'
有没有办法将行分成单独的行?
提前致谢
最佳答案
您似乎想将其打印为一个大字符串,而不是将各个项目分开。
为此你可以这样做:
for element in tagall:
print(",".join(element))
如果你想将其分成单独的行,你可以这样做
for element in tagall:
for item in element:
print(item) #but this doesn't need a comma because they are on separate lines
关于python - 如何将 pyodbc.row 拆分为其值列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21884966/