Python中文
首页
教程
问答
标签
搜索
登录
注册
如果找到字符串,则连接到字符串旁边
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我试图搜索我的字符串,然后连接字符串。你知道吗</p> <pre><code>string = ' <html><body><svg style="background: #40484b;" version="1.1" viewbox="0 0 400 150" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <defs> <!-- if you use the same shape multiple times, you put the reference here and reference it with <use> --> <rect height="100" id="path-1" width="100" x="25" y="25"></rect> <rect height="100" id="path-3" width="100" x="150" y="25"></rect> <rect height="100" id="path-5" width="100" x="275" y="25"></rect> <!-- gradient --> <lineargradient id="gradient" x1="50%" x2="50%" y1="0%" y2="100%"> <stop offset="0%" stop-color="#FF8D77"></stop> <stop offset="50%" stop-color="#FFBDB1"></stop> <stop offset="100%" stop-color="#F4E3F6"></stop> </lineargradient> <!-- clip-path --> <clippath id="clip"> <circle cx="325" cy="75" r="50"></circle> </clippath> <!-- filter --> </defs>> <g fill-rule="evenodd"> <use fill="#FF8D77" fill-opacity="0.5" filter="url(#glow)" xlink:href="#path-1"></use> <use fill="url(#gradient)" xlink:href="#path-3"></use> <use clip-path="url(#clip)" fill="#FF8D77" xlink:href="#path-5"></use> </g> </svg> </body></html>' </code></pre> <p>我的绳子就是这样的。 到目前为止,这就是我所拥有的</p> <pre><code> string_list = string if "<defs>" in string: ###I'm trying to concatenate strings after <defs> like <defs> string string </code></pre> <p>另外,我想继续附加字符串而不是替换。例如,如果我在某个对象中有一个用户类型,它会在defs之后不断添加字符串,而不是替换我已有的字符串。你知道吗</p> <p>我期望的输出是这样的,我添加了“concatenated string1”和“concatenated string2”。我试图在我的字符串列表中的“defs”旁边添加字符串。你知道吗</p> <p>另外,我所说的不断添加字符串而不是替换的意思是例如。 我有一个 -字符串“concatenae1”中的第一个用户类型 -字符串“concatenate2”中的第二个用户类型 我想在我的defs标签旁边添加两个concatenate 1+contatenate 2。你知道吗</p> <pre><code><html><body><svg style="background: #40484b;" version="1.1" viewbox="0 0 400 150" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <defs> <concatenated string1> <concatenated string2> <!-- if you use the same shape multiple times, you put the reference here and reference it with <use> --> <rect height="100" id="path-1" width="100" x="25" y="25"></rect> <rect height="100" id="path-3" width="100" x="150" y="25"></rect> <rect height="100" id="path-5" width="100" x="275" y="25"></rect> <!-- gradient --> <lineargradient id="gradient" x1="50%" x2="50%" y1="0%" y2="100%"> <stop offset="0%" stop-color="#FF8D77"></stop> <stop offset="50%" stop-color="#FFBDB1"></stop> <stop offset="100%" stop-color="#F4E3F6"></stop> </lineargradient> <!-- clip-path --> <clippath id="clip"> <circle cx="325" cy="75" r="50"></circle> </clippath> <!-- filter --> </defs>> <g fill-rule="evenodd"> <use fill="#FF8D77" fill-opacity="0.5" filter="url(#glow)" xlink:href="#path-1"></use> <use fill="url(#gradient)" xlink:href="#path-3"></use> <use clip-path="url(#clip)" fill="#FF8D77" xlink:href="#path-5"></use> </g> </svg> </body></html> </code></pre>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>对于包含多行的字符串,应该使用三重单引号或三重双引号。最好使用“for”循环,而不是“if”语句。你知道吗</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
无法使用Django restfram生成PDF
5 回答
无法使用Django Rest框架发送压缩的gzip数据
10 回答
无法使用Django rest框架进行身份验证(请求用户=匿名用户)
1 回答
无法使用Django、Python和JavaScrip触发onclick函数
6 回答
无法使用Django.views.generic.View保存表单
4 回答
无法使用Django(python 2.7,OS X 10.11.1)
9 回答
无法使用Django/mongoengine连接到MongoDB(身份验证失败)
8 回答
无法使用Django\u mssql\u后端迁移到外部hos
10 回答
无法使用Django&Python3.4连接到MySql
5 回答
无法使用Django+nginx上载媒体文件
4 回答
无法使用Django1.6导入名称模式
7 回答
无法使用Django1.7和mongodb登录管理站点
4 回答
无法使用Djangoadmin创建项目,进程使用了错误的路径,因为我事先安装了错误的Python
7 回答
无法使用Djangockedi验证CBV中的字段
5 回答
无法使用Djangocketditor上载图像(错误400)
8 回答
无法使用Djangocron进行函数调用
7 回答
无法使用Djangofiler djang上载文件
8 回答
无法使用Djangokronos
8 回答
无法使用Djangomssql provid
3 回答
无法使用Djangomssql连接到带有Django 1.11的MS SQL Server 2016
2 回答