核爆吧 关注:159贴子:175
  • 3回复贴,共1
1. score = int ( input ('请输入一个整数:'))
2.
degree =' DCBAAF '
3. if score >100 or score <0:
4.
print (' wrong score . must between 0 and 100.')
5.
else :
6.
index =( score -60)//10
7.
if index >=0:
8.
print ( degree [ index ])
9.
else :
10.
print ( degree [-1])


IP属地:广东来自Android客户端1楼2023-10-23 11:04回复
    import os
    import os. path
    os. path. exists("E: MpythonProject|\data.txt")##X os. path. exists("E:\\pythonProject\\datal.txt")#判断文件是os.path.basename(E:\\pythonProject\\data.txt")#返回指定路os.path.isfile(E:\\pythonProject\\data.txt")#判断是否为文os. remove(E:\\pythonProject\\data.txt")# 删除指定文件os.listdir(E:pythonProject")


    IP属地:广东来自Android客户端2楼2023-11-20 10:49
    回复
      os . path . split ( E : WpythonProject Wdata . txt )# Wiz # os . path . dirname ( E : pythonProject \(\ datatxt )## i
      = os . path 模块常用文件操作方法2
      import os
      import os . path
      os . path . exists (" E : ApythonPro . ject \\ data . txt ")=判断文作是: os . path . exists ( E : pythonProject \' datal , txt ")#判断文件是 os . path . basename ( E : pythonProjectyadata . txt )= Saint ) os . path , istlie C : sApythonProjectyidats . txt "),"的瞧是否为文 os . removel Et pythonProject / Vdata .txt7) e Rir :/指定文件 os . listbir El
      onfrojece s
      s Cane 历关下的所有文


      IP属地:广东来自Android客户端3楼2023-11-20 10:50
      回复
        import re
        #任务实现
        # 1.读取数据
        with open(walden.txt',"r)as f##
        txt = f. read()
        网页链接 #2.去除多余符号
        lyric= txt. lower 0
        #将大写字母转换成小写形式
        lyric_new = re. sub('[,.:"\'?\n:-]','',lyrie)#去除多余的标点符号
        #3.单词分割
        words = lyric_new. split()
        # 4.词频统计
        word_freq = 0}
        for word in words:
        word_freq[word] = word_freq, get(word, 0) +1
        # 5.排序
        result =sorted(word_freq.items(),key=1ambda x: x[1],reverse True)
        #6、写出结果
        result_string = str(result):将结果转换成字符串形式
        with open(word_freq,txt',mode='w')an f:
        f.write(result_string)


        IP属地:广东来自Android客户端4楼2023-11-20 11:36
        回复