remove-non-numeric-string

Remove non numeric string

  
str='%1b4k&vwe@8s'  
  
def clean(str):  
	result = []  
	r =''  
	for i,j in enumerate(str):  
		if (not j.isalnum()) and i>0:  
			result.append(str[i-1])  
		else:  
			result.append(j)  
	return r.join(result)  
  
clean(str)  
  

Back to top

Copyright © 2019 - 2024 Johnny Li. All contents licensed under CC BY-NC-SA 4.0 本站所有内容基于 CC BY-NC-SA 4.0 协议发布,转载需要署名.
Please read the LICENSE file for specific language governing permissions and limitations under the License.

Page last modified: Apr 16 2024 at 09:36 PM.

Edit this page on GitHub