将空格转换为列表中的%20 [英] Convert spaces to %20 in list

查看:127
本文介绍了将空格转换为列表中的%20的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将python数组中api帖子的空格转换为%20

I need to convert spaces to %20 for api posts in a python array

tree = et.parse(os.environ['SPRINT_XML'])
olp = tree.findall(".//string")
if not olp:
  print colored('FAILED', 'red') +" No jobs accociated to this view"
  exit(1)
joblist = [t.text for t in olp]

如何对上面的t.text进行操作?

How can I do that to t.text above?

推荐答案

使用String.replace()方法,如下所述: http ://www.tutorialspoint.com/python/string_replace.htm

Use the String.replace() method as described here: http://www.tutorialspoint.com/python/string_replace.htm

所以对于t.text,它应该是t.text.replace(" ", "%20")

这篇关于将空格转换为列表中的%20的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆