简体   繁体   English

如何将包含单个值的单个字符串分开

[英]How do I separate a single string containing to individual values

I have two strings the first is:我有两个字符串,第一个是:

a = str(7.19% 8.16%)

and I would like to store this as two different strings as seen below:我想将其存储为两个不同的字符串,如下所示:

b = str(7.19%) 
c = str(8.16%)

I have two strings the first is:我有两个字符串,第一个是:

a = str(7.19% 8.16%)

and I would like to store this as two different strings as seen below:我想将其存储为两个不同的字符串,如下所示:

b = str(7.19%) 
c = str(8.16%)

This is a one liner这是单班轮

a = '7.19% 8.16%'
b,c=a.split(' ')
print(b,c)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python 2-如何导入包含一长串数字的文本文件并将其转换为单个数字字符串? - Python 2 - How do I import a text file containing a long sequence of digits and convert it to a string of individual numbers? 如何获取单个行的值? - How do I get values of an individual row? 如何在Python中将JSON文件分离为单个JSON对象 - How do I separate a JSON file to individual JSON objects in Python 如何在Python中使用xlrd从单个单元格中获得多个值,并用逗号分隔多个值? - How do I get separate values from a single cell with multiple values in it separated by commas using xlrd in Python? 如何识别字符串中的单个字符 - How do I identify individual characters in a string Python:如何从包含单引号(撇号)的输入中匹配 dataframe 中的值? - Python: how do I match values in the dataframe from an input containing single quotes (apostrophe)? Python和Pandas:如何从单个列中缩短字符串值? - Python and Pandas: How do I shorten string values from an individual column? 我有一个包含字典的元组列表。 如何在这些词典中编辑我的代码以在单独的列表中查找值? - I have a list of tuples containing dictionaries. How do I edit my code to find the values in a separate list, inside these dictionaries? 如何将包含多个数字的单个字符串列表拆分为分隔整数列表? - How do I split a list of a single string containing multiple numbers into a list of separated integers? 如何将字符串分成多行单个字符 - How to separate a string into multiple lines of individual characters
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM