# -*- coding: utf-8 -*- # %% jira import codecs from jira import JIRA jira = JIRA('http://oa.wanpinghui.com', auth=('郑毅', 'GraphQL6')) issue = jira.issue('XXH-353') filename = './test.csv' def write_bom(): with open(filename, 'w') as f: # create a new file,overwrite when the file was existed f.write(codecs.BOM_UTF8) # write utf8 BOM at starts of the file def write_line(*args): raw = ','.join(args).encode('utf-8') # append a line of content into the file with open(filename, 'a') as f: f.write('%s\n' % raw) write_bom() for i in range(5): write_line(issue.fields.project.key, issue.fields.issuetype.name, issue.fields.reporter.displayName)