Python字符转换
2023-06-13 09:14:02 时间
如:
>>>printord("a")
97
>>>printchr(97)
a
下面我们可以开始来设计我们的大小写转换的程序了:
复制代码代码如下:
>>>printord("a")
97
>>>printchr(97)
a
下面我们可以开始来设计我们的大小写转换的程序了:
#!/usr/bin/envpython
#coding=utf-8
defUCaseChar(ch):
iford(ch)inrange(97,122):
returnchr(ord(ch)-32)
returnch
defLCaseChar(ch):
iford(ch)inrange(65,91):
returnchr(ord(ch)+32)
returnch
defUCase(str):
return"".join(map(UCaseChar,str))
defLCase(str):
return"".join(map(LCaseChar,str))
printLCase("ABC我abc")
printUCase("ABC我abc")
abc我abc
ABC我ABC
相关文章
- python十进制转换_Python 进制转换
- python的进制转换器,Python进制转换[通俗易懂]
- 利用python实现易班疫情自动签到
- python实现求和,求平均值——函数
- python 中进制转换及format(),int()函数用法「建议收藏」
- Python基本数据类型-Number
- python实现量化交易策略
- Python里divmod_python yield函数
- Python标识符的命名规则,下列哪些是对的?_python标识符不能使用关键字
- python把数字转换为字符串_python中将列表转化为字符串
- python数字转字符串固定位数_python-将String转换为64位整数映射字符以自定…「建议收藏」
- Python基础语法-表达式(二)
- Python基础语法-函数的错误处理-常见异常类型
- python-Python与SQLite数据库-处理SQLite查询结果(二)
- python-Python与PostgreSQL数据库-处理PostgreSQL查询结果
- python通过ftp上传文件详解编程语言
- python代码实例大小写转换,首字母大写,去除特殊字符详解编程语言
- 快速安装Python MySQL模块(python安装mysql模块)
- 学习 Python 的 12 个方式
- Python实现MySQL数据库的读取(python读取mysql)