我有一个从 Python 连接到 MySQL 数据库的应用程序。
我想从每个表中的每个条目中删除所有新行、制表符和多余的空格。
我可以这样做吗,例如使用update
and split
?
这是我的第一步:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import MySQLdb as mdb
con = mdb.connect('localhost', 'USER', 'PASSWORD', 'DATABASE');
with con:
cur = con.cursor()
cur.execute("SELECT * FROM TABLE_NAME LIMIT 1")
rows_1 = cur.fetchall()
print rows_1
for row in rows_1:
inString = rows_1;
str = inString.replace("\n", "");
print row
exit(0)