简体   繁体   English

从 python 中的字符串中拆分整数

[英]Spliting integers from string in python

Suppose I have a numpy array like -假设我有一个 numpy 数组,例如 -

A = ['83.56%' '2.74%' '2.74%' '4.11%' '4.11%' '19.18%' '76.71%' '20.55%'
 '34.25%' '54.79%']

and I want to split this array as integers array only like -我只想将此数组拆分为整数数组,例如 -

B = ['83.56' '2.74' '2.74' '4.11' '4.11' '19.18' '76.71' '20.55'
 '34.25' '54.79']

How should I do it using Python codes?我应该如何使用 Python 代码进行操作?

Use-case for str.rstrip : str.rstrip的用例:

B = [item.rstrip('%') for item in A]

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

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