今天遇到的字符串处理的问题,记录一下方便使用 str1 = input('请输入一个字符:') #初始化字符.数字.空格.特殊字符的计数 lowercase = 0 uppercase = 0 number = 0 space = 0 other = 0 for strs in str1: #如果在字符串中有小写字母,那么小写字母的数量+1 if strs.islower(): lowercase += 1 #如果在字符串中有数字,那么数字的数量+1 elif strs.isdigit(): n
Python不使用int()函数把字符串转换为数字 2018年05月21日 14:18:45 边缘ob边缘ob 阅读数:1035 https://blog.csdn.net/qq_33192555/article/details/80391554 方法一:利用str函数 既然不能用int函数,那我们就反其道而行,用str函数找出每一位字符表示的数字大写. def atoi(s): s = s[::-1] num = 0 for i, v in enumerate(s): for j in r
Python 基础:字符串,数字,变量 1. 字符串 (信息的一种表达方式) a. 使用引号创建字符串 b. 单引号,双引号,三引号: ', ", ''', """ c. print函数: print('hello', end=',');print('world', end=';') d. 和字符串显示格式相关的应该想到print函数,print函数可以指定不同的结束字符串. e. ascii art """ ##### #######