华为机考入门python3--(33)牛客33-图片整理

分类:排序

知识点:

  1. 对字符串中的字符ASCII码排序 sorted(my_str)

题目来自【牛客】

python 复制代码
def sort_images(s):
    # 可以使用ord('A')求A的ASCII值,需要注意的是A的值(65)比a的值小(97)
    sorted_images = sorted(s)  # 对字符串中的字符进行排序
    return ''.join(sorted_images)  # 将排序后的字符列表连接为字符串并返回

# 输入
input_str = input()

# 对字符进行排序并输出结果
result = sort_images(input_str)
print(result)
相关推荐
Ricardo-Yang15 小时前
SCNP语义分割边缘logits策略
数据结构·人工智能·python·深度学习·算法
凌波粒15 小时前
LeetCode--344.反转字符串(字符串/双指针法)
算法·leetcode·职场和发展
啊哦呃咦唔鱼15 小时前
LeetCode hot100-543 二叉树的直径
算法·leetcode·职场和发展
Utopia^15 小时前
Flutter 框架跨平台鸿蒙开发 - 起床战争
flutter·华为·harmonyos
soragui15 小时前
【Python】第 4 章:Python 数据结构实现
数据结构·windows·python
autumn200515 小时前
Flutter 框架跨平台鸿蒙开发 - 习惯养成塔
flutter·华为·harmonyos
和小潘一起学AI16 小时前
CentOS 7安装Anaconda
开发语言·python
李李李勃谦16 小时前
Flutter 框架跨平台鸿蒙开发 - 决策硬币
flutter·华为·harmonyos
kcuwu.16 小时前
Python 正则表达式从入门到实战
数据库·python·正则表达式
不解不惑16 小时前
langchain qwen3 构建一个简单的对话系统
pytorch·python·langchain