全部日记
22 条记录2025 / 12
- 平静
2小时之Python入门 哈哈哈哈,重生之我在VSCode被GPT教学Python,光速入门哈哈哈 混了那么久的程序员这个圈子今天才刚开始学编程,下面直接放我2小时的最终成功,是GPT给我题目让我自己动手写的,题目如下: 🎯 练手题目:统计多种字符类型(函数版) 任务: 用户输入一句话 写四个函数: count_vowels(text) → 返回元音数量 count_numbers(text) → 返回数字数量 count_spaces(text) → 返回空格数量 count_other_letters(text) → 返回除元音以外的字母数量 主程序里调用这四个函数,然后打印结果: 输入一句话:Hello World 123 元音字母数量:3 数字数量:3 空格数量:2 其他字母数量:7 要求: 每个函数用 for + if / elif / else 遍历和判断 每个函数必须用 return 返回结果 主程序只负责调用函数和打印结果 我的答案当然不是一次性写对的,被纠错了两次 最开始我就知道我错了,但是不知道怎么改,初稿如下 ```python def count_yuanyin(text): yuanyins = ['a', 'e', 'i', 'o', 'u',] yuanyin = 0 for ch in text: f ch in yuanyin: yuanyin += 1 return yuanyin def count_shuzi(text): shuzis = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] shuzi = 0 for ch in text: if ch in shuzis: shuzi += 1 return shuzi def count_kongge(text): kongges = [' '] kongge = 0 for ch in text: if ch in kongges: kongge += 1 return kongge def count_other(text): other = 0 for ch in text: if ch != shuzi and ch != yuanyin and ch !=kongge: other += 1 return other text = input("请输入一段文本:") yuanyin = count_yuanyin(text) shuzi = count_shuzi(text) kongge = count_kongge(text) other = count_other(text) print("元音字母有", yuanyin , "个") print("数字有", shuzi , "个") print("空格有", kongge , "个") print("其他字符有", other , "个") ``` 虽然写错了但是感觉也差不多嘛 下面是最终答案 ```python def count_yuanyin(text): yuanyins = ['a', 'e', 'i', 'o', 'u',] yuanyin = 0 for ch in text: if ch in yuanyins: yuanyin += 1 return yuanyin def count_shuzi(text): shuzis = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] shuzi = 0 for ch in text: if ch in shuzis: shuzi += 1 return shuzi def count_kongge(text): kongges = [' '] kongge = 0 for ch in text: if ch in kongges: kongge += 1 return kongge def count_other(text): shuzis = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] yuanyins = ['a', 'e', 'i', 'o', 'u'] kongges = [' '] other = 0 for ch in text: if ch not in shuzis and ch not in yuanyins and ch not in kongges: other += 1 return other text = input("请输入一段文本:") yuanyin = count_yuanyin(text) shuzi = count_shuzi(text) kongge = count_kongge(text) other = count_other(text) print("元音字母有", yuanyin , "个") print("数字有", shuzi , "个") print("空格有", kongge , "个") print("其他字符有", other , "个") ``` 感觉不错(╹ڡ╹ ) 好玩😋😋😋
- 平静
淘宝闪购真牛逼 我也不想给淘宝闪购打广告😭😭😭😭,但是他真的好便宜😭😭😭
- 平静
第一次喝Idrink的水果茶 今天次仁群培请了我一杯吾饮良品的葡萄奶绿水果茶,好喝耶耶耶!
- 平静
第一次望远镜观月 今天第一次用天文望远镜赏月,赏的还是超级月亮,本来似乎是说还有流星会掠过月亮能被看见,但是等到10:50还没有,怕被记晚归就回寝室了。但是大部分的人都在10点左右就走光了,只剩三四个人了,因此我也有机会去看看其他的星星。 图5是五车二距离我们42光年,图6,7是天狼星,距离我们9光年,尤其是五车二,我用眼睛都看不见,在手机软件上找准位置才对准拍照的,虽然完全拍不出来哈哈哈哈,毕竟望远镜只有108mm口径,我下回想玩信达小黑😭 对了,晚上是真的冷啊😭😭😭
2025 / 10
- 平静
第一次上手组装天文望远镜 第一次上手装天文望远镜,两人一组,前面几组都很慢,我这一组的另一个是大佬,他说他不用,让我来,然后指导我,我也是光速组装完成了耶:)
2025 / 09
- 平静
Online I'm like a ghosst on the internet. Whenever someone thinks of me. In the brain, there will be that night in the eternal and unchanging silence forest. The unusual and strange and unsatusifying one. “Online”
2023 / 07
- 平静
蓝海小方块 以前很喜欢的的一个小玩意,下定决心还是买了,虽然才几块钱