上一页 1 2 3 4 5 6 7 8 9 ··· 44 下一页
摘要: 这是把'\n'也解析去了,导致多格式化输入了一次了 package main import ( "fmt" "math/rand" "time" ) func init() { rand.Seed(time.Now().UnixNano()) } func main() { target := ra 阅读全文
posted @ 2023-02-12 10:03 ty1539 阅读(32) 评论(0) 推荐(0) 编辑
摘要: def selection_sort(alist): n = len(alist) # 需要进行n-1次选择操作 a = 0 for i in range(n-1): # 记录最小位置 min_index = i exit = i # 从i+1位置到末尾选择出最小数据 for j in range( 阅读全文
posted @ 2022-12-18 12:54 ty1539 阅读(15) 评论(0) 推荐(0) 编辑
摘要: # Start with a list of numbers that ain't sorted numbers=[0,5,1,4,2,8] # Keep track of whether any swaps were made on the previous i teration # If no 阅读全文
posted @ 2022-12-10 11:57 ty1539 阅读(21) 评论(0) 推荐(0) 编辑
摘要: #_*_ encoding: utf-8 _*_ @author: ty hery 2018/10/6 # 发送邮件失败了 import smtplib #加载smtplib模块 from email.mime.text import MIMEText from email.utils import 阅读全文
posted @ 2022-11-20 20:45 ty1539 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 1, 速度很快, 唯一缺陷是计数长度列表和排序的最大数字相等, 如果排序中的数字实在太大了, 创建的列表太长了比如2的32次方 import random def count_sort(li, max_count =21): count = [0 for _ in range(max_count+1 阅读全文
posted @ 2022-11-13 15:04 ty1539 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 如果要使用classonlymethod ,则需要先定义好一个classonlymethod 类。 首先我们需要明白无论是classonlymethod还是classmethod,本质都是一个类,而classonlymethod继承了classmethod。 classonlymethodz作用:只 阅读全文
posted @ 2022-11-06 20:47 ty1539 阅读(106) 评论(0) 推荐(1) 编辑
摘要: import unittest class MyTestCase(unittest.TestCase): def test_something(self): self.assertEqual(0, False) if __name__ == '__main__': unittest.main() 输 阅读全文
posted @ 2022-11-06 17:25 ty1539 阅读(33) 评论(0) 推荐(0) 编辑
摘要: 冒泡排序分析详细节情版 import random def bubble(li): for i in range(len(li)-1): exchange = False for j in range(len(li)-i-1):`` if li[j] > li[j+1]: print('%s-%s哈 阅读全文
posted @ 2022-10-26 08:32 ty1539 阅读(19) 评论(0) 推荐(0) 编辑
摘要: class Foo: def __init__(self,name): self.name = name def __getitem__(self,item): print('getitem') print(item) return self.__dict__.get[item] def __set 阅读全文
posted @ 2022-10-22 19:58 ty1539 阅读(16) 评论(0) 推荐(0) 编辑
摘要: class People(object): color = 'yellow' #这就是一个公有属性,可以在类里和类外调用 __age = 30 #这就是一个私有属性,只能在类里调用。 def think(self): self.color = "black" print ("i am a %s" % 阅读全文
posted @ 2022-10-22 19:56 ty1539 阅读(16) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 44 下一页