简体   繁体   中英

replace single quotes with backticks

I need to enclose every list element with backticks `` so that the code can be sent to frontend. Basically, replace single quotes with backticks Below is the list in which I need to make the change.

['<table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td>
          <link
            href="https://www.moneycontrol.com/rss/latestnews.xml"
            rel="alternate"
            title="MoneyControl.com News"
            type="application/rss+xml"
          />
        </td>
      </tr>
    </table>',
    '<table cellpadding="0" cellspacing="0" class="rhsglTbl" width="100%">
      <thead>
        <tr>
          <th width="120">Index</th>
          <th width="80">Price</th>
          <th width="55">Change</th>
          <th width="50">% Chg</th>
        </tr>
      </thead>
    </table>']

This change is required so that I can iterate through each element and add it to an accordian .

like this?

backticked = [ f"`{x}`" for x in your_list ]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM