首页
金蝶系列
用友系列
鼎捷系列
OA协同办公
注册/登录
登录
注册
Search
1
Python 3.8 - ModuleNotFoundError: No module named 'flask._compat'
259 阅读
2
CentOS 7 - 安装iredMail 邮件服务器
252 阅读
3
Zabbix 4.0 源码安装
221 阅读
4
Kingdee-采购管理-T_PUR_CATALOGENTRY_R-采购目录_关联信息表
189 阅读
5
Python循环语句- for
179 阅读
默认分类
Windows
金蝶
OA
ERP
帆软
用友
Linux
数据库
/
Search
标签搜索
金蝶
管理
美萍
OA
Linux
qq
泛微
获取
破解
监控
用友
IPguard
KIS
Zabbix
python
帆软
活字格
MySQL
FineReport
k3cloud
SOSO
累计撰写
299
篇文章
累计收到
5
条评论
首页
栏目
默认分类
Windows
金蝶
OA
ERP
帆软
用友
Linux
数据库
页面
金蝶系列
用友系列
鼎捷系列
OA协同办公
推荐
登录
注册
搜索到
7
篇与
的结果
2022-05-09
Python 数据类型之-字符串
一、 常见字符串函数字符串操作描述string.capitalize()将字符串的第一个字母大写string.count()获得字符串中某一子字符串数量string.find()获得字符串中某一子字符串的起始位置, 无则返回 -1string.isalnum()检测字符串是仅包含0~9A~Za~zstring.isalpha()检测字符串是仅包含A~Za~zstring.isdigit()检测字符串是仅包含数字string.islower()检测字符串是否均为小写字母string.isupper()检测字符串是否均为大写字母string.isspace()检测字符串中所有字符是否均为空白字符string.istitle()检测字符串中的单词是否为首字母大写string.join()连接字符串string.lower()将字符串全部转换为小写string.upper()将字符串全部转换为大写string.split()分割字符串string.swapcase()将字符串中大写字母转換为小写,小写字母转为大写string.title()将字符串中的单词首字母大写len(string)获取字符串长度1.1 将字符串中的第一个字母大写In [1]: str = "python" In [2]: print(str.capitalize()) Python1.2 获得字符串中某一子字符串数量In [3]: str = "i love python" In [4]: print(str.count('o')) 21.3 获得字符串中某一子字符串的起始位置, 无则返回 -1In [5]: str = "i love python" In [6]: print(str.find('p')) 71.4 检测字符串是仅包含0~9A~Za~zIn [15]: str = "i love python" In [16]: print(str.isalnum()) False In [17]: str1 = 'abcd123ABC' In [18]: print(str1.isalnum()) True1.5 检测字符串是仅包含A~Za~zIn [19]: str = "i love python" In [20]: print(str.isalpha()) False In [21]: str1 = 'abcdABC' In [22]: print(str1.isalpha()) True1.6 连接字符串In [30]: str1 = 'abc' In [31]: str2 = '123' In [32]: str1.join(str2) Out[32]: '1abc2abc3'1.7 分割字符串In [33]: str = 'abcdefg123' In [34]: str.split('c') Out[34]: ['ab', 'defg123'] In [35]: str = 'abc, def, ghi' In [36]: str.split(',') Out[36]: ['abc', ' def', ' ghi'] # 指定分割次数 In [72]: str.split(' ',1) Out[72]: ['I', 'love python'] # 或 In [73]: str.split(' ', maxspli=1) Out[73]: ['I', 'love python']1.8 字符串大小写转换In [44]: str = 'abc' In [45]: print(str.upper()) ABC In [46]: str = 'ABC' In [47]: print(str.lower()) abc In [48]: str = 'abcdEFGH' In [49]: print(str.swapcase()) ABCDefgh1.9 获取字符串长度In [54]: str = 'abcd123' In [55]: len(str) Out[55]: 7二、格式化字符串格式化说明%c单个字符%d十进制整数%o八进制整数%s字符串%x十六进制整数,其中的字母小写%X十六进制整数,其中的字母大写2.1 格式化 %sIn [28]: str = 'Python' In [29]: strFormat = "I love %s" % str In [30]: strFormat Out[30]: 'I love Python'2.2 格式化 %dIn [31]: num1 = 10 In [32]: num2 = 20 In [33]: result = num1 + num2 In [34]: print("%d + %d = %d" % (num1, num2, result)) 10 + 20 = 30
2022年05月09日
83 阅读
0 评论
0 点赞
2022-04-25
Python 3.8 - ModuleNotFoundError: No module named 'flask._compat'
Python 3.8 报错 No module named 'flask._compat'C:\Users\name\PycharmProjects\untitled>python manage.py server Traceback (most recent call last): File "manage.py", line 1, in <module> from flask_script import Manager, Server File "C:\Python38\lib\site-packages\flask_script\__init__.py", line 15, in <module> from flask._compat import text_type ModuleNotFoundError: No module named 'flask._compat' 修改 flask_script/__init__.py 文件from flask._compat import text_type --- 修改为: from flask_script._compat import text_type
2022年04月25日
259 阅读
0 评论
0 点赞
1
2