删除python代码

时间:2017-03-22 12:31:55

标签: python

如何删除重复的print语句issue_assign并转到下一行。输出应该是这样的。

目前我的打印输出如下所示:

  

指定

     

Key,Summary,Reporter,Name,Resolution,Createdate,UpdateDate,Due,Team

     

指定

     

Key,Summary,Reporter,Name,Resolution,Createdate,UpdateDate,Due,Team

     

...

我希望输出像这样,没有任何重复。

  

指定

     

Key,Summary,Reporter,Name,Resolution,Createdate,UpdateDate,Due,Team

     

Key,Summary,Reporter,Name,Resolution,Createdate,UpdateDate,Due,   队

     

...

我的代码看起来像这样

def assigne(username):
    responses = fetch(server + Ticket_Week + ' and assignee='+ username)

    duplicate = []
    object = {}
    for issue in responses['issues']:
        issue_fields = issue['fields']
        issue_status = issue_fields['status']
        issue_reporter = issue_fields['reporter']['displayName']
        issue_created = issue_fields['created']
        issue_updated = issue_fields['updated']
        issue_assign = 'Unassigned'
        issue_resolution = 'Unresolved'
        issue_due = 'null'
        issue_serviceteam = 'null'
        issue_createdate = datetime.datetime.strptime(issue_created[:-5], '%Y-%m-%dT%H:%M:%S.%f').strftime("%m/%d/%y")
        issue_updatedate = datetime.datetime.strptime(issue_updated[:-5], '%Y-%m-%dT%H:%M:%S.%f').strftime("%m/%d/%y")

        if issue_fields['assignee']:
            issue_assign = issue_fields['assignee']['displayName']
        if issue_fields['resolution']:
            issue_resolution = issue_fields['resolution']['name']
        if issue_fields.get('duedate', None):
            issue_due = issue_fields['duedate']
        if issue_fields.get('customfield_10506', None):
            issue_serviceteam = issue_fields['customfield_10506']['name']
        print(issue_assign)
        print(issue['key'], issue_fields['summary'], issue_reporter, issue_status['name'], issue_resolution, issue_createdate, issue_updatedate, issue_due, issue_serviceteam)

1 个答案:

答案 0 :(得分:0)

如果问题出在<?php include('includes/db_connection.php'); include('includes/sessions.php'); include('includes/functions.php'); include('includes/header.php'); include('includes/navbar-logged.php'); // who is the admin sending the email? $row = DB::getInstance()->selectOneByField('membership', 'member_username', $member); $admins_id = $row['member_id']; ?> <div id="insert-text"></div> <div class="panel panel-primary"> <div class="panel-heading">Mass e-mail all users.</div> <div class="panel-body"> <form id="frmAjax" action="mass-email.php" method="post" class="form-horizontal container-fluid" role="form"> <div class="row form-group"> <div class="col-sm-4 text-right"><label for="txtMessage" class="control-label">Message:</label></div> <div class="col-sm-8"> <textarea id="" name="message" class="form-control" required="required"></textarea> </div> </div> <div class="row form-group"> <div class="col-sm-12 text-right"> <button type="submit" name="submit" class="btn btn-default">Send</button> </div> </div> </form> </div> <div class="panel-footer">Send a mass e-mail to <b>all users</b> currently registered.</div> </div> <script> $('#frmAjax').submit(function(e) { e.preventDefault(); // important so the submit doesn't clear the data... var txtAreaValue = document.getElementsByTagName("textarea")[0].value; $.post('ajax-emails.php', {txtAreaValue:txtAreaValue}, function (data) { //alert(txtAreaValue); }); $('#insert-text').load('ajax-emails.php'); }); </script> <?php include('includes/footer.php'); 上,则引入布尔变量<?php include('includes/db_connection.php'); include('includes/functions.php'); // mass email $result = DB::getInstance()->selectAll('membership'); // loop through the emails foreach ($result as $row) { $email = $row['member_email']; $username = $row['member_username']; $message = nl2br($_POST['txtAreaValue']); $message = stripslashes($message); echo $message; //$mailSent = sendMassEmail($email, $username, $message); echo "<b>email sent to: <font color='green'>".$email."</font></b>"; } ?>

i

编辑(根据评论):

如果您有多个用户,您有多个选项,但我会强调两个:

假设您的用户名是1,2,3和4:

print(issue_assign)

在我看来,其他选择是更好的解决方案:

def assigne(username):

    responses = fetch(server + Ticket_Week + ' and assignee='+ username)

    duplicate = []
    object = {}
    i = True
    for issue in responses['issues']:
        issue_fields = issue['fields']
        issue_status = issue_fields['status']
        issue_reporter = issue_fields['reporter']['displayName']
        issue_created = issue_fields['created']
        issue_updated = issue_fields['updated']
        issue_assign = 'Unassigned'
        issue_resolution = 'Unresolved'
        issue_due = 'null'
        issue_serviceteam = 'null'
        issue_createdate = datetime.datetime.strptime(issue_created[:-5], '%Y-%m-%dT%H:%M:%S.%f').strftime("%m/%d/%y")
        issue_updatedate = datetime.datetime.strptime(issue_updated[:-5], '%Y-%m-%dT%H:%M:%S.%f').strftime("%m/%d/%y")

        if issue_fields['assignee']:
            issue_assign = issue_fields['assignee']['displayName']
        if issue_fields['resolution']:
            issue_resolution = issue_fields['resolution']['name']
        if issue_fields.get('duedate', None):
            issue_due = issue_fields['duedate']
        if issue_fields.get('customfield_10506', None):
            issue_serviceteam = issue_fields['customfield_10506']['name']



        if i:
            print(issue_assign)
            i = False
        print(issue['key'], issue_fields['summary'], issue_reporter, issue_status['name'], issue_resolution, issue_createdate, issue_updatedate, issue_due, issue_serviceteam)

通过这种方式,您可以将用户名转发为单个用户名,也可以使用用户名列表调用您的用户名。