import urllib
import csv
@manager.command
def list_routes():
for rule in app.url_map.iter_rules():
options = {}
for arg in rule.arguments:
options[arg] = "[{0}]".format(arg)
url = rule.rule
line = urllib.parse.unquote("{}{} ".format(rule.endpoint, url))
with open('urls.cvs', 'a') as out:
spamwriter = csv.writer(out, lineterminator='', dialect='excel')
spamwriter.writerows(line)
spamwriter.writerows('\n')
我需要填寫csv文件,以便rule.endpoint和url具有單獨的列。使用Python分割CSV文件中的列的值
你有不正確的凹痕。 – furas
嘗試'line = urllib.parse.unquote(「{},{}」.format(rule.endpoint,url))''然後''writerow'而不是''編輯器' – roganjosh