python ascii 排序 sorted默认排序

图片整理

http://www.nowcoder.com/questionTerminal/2de4127fda5e46858aa85d254af43941

大神答案。
sorted对字符串str 对排序默认是按照ascii码进行排序。

while True:
    try:
        print("".join(sorted(input())))
    except:
        break

个人答案,测试时间超过2秒。

while True:
    try:
        in_str=input()
        in_list = [x for x in in_str]
        out_list = sorted(in_list,key = ord)
        out_str =''.join(out_list)
        print(out_str)
    except:
        pass
全部评论
你把你的pass改成break 一样也能过
1 回复 分享
发布于 2020-10-14 23:34

相关推荐

09-01 11:31
门头沟学院 Java
buul:七牛云的吧,感觉想法是好的,但是大家没那么多时间弄他这个啊。。。不知道的还以为他是顶尖大厂呢还搞比赛抢hc,只能说应试者的痛苦考察方是无法理解的,他们只会想一出是一出
点赞 评论 收藏
分享
存一下准备挨个投一下
小小:银行秋招真题,欢迎大家来刷:牛客 -> 题库 -> 国央企笔试真题 。https://www.nowcoder.com/exam/company?questionJobId=195&subTabName=written_page
点赞 评论 收藏
分享
评论
2
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务