02 2023 档案
摘要:import re re.match #从开始位置开始匹配,如果开头没有则无 re.search #搜索整个字符串 re.findall #搜索整个字符串,返回一个list
阅读全文
摘要:内建函数 help() help(list.append) #显示list的append方法的帮助 input() name=input('please enter your name:') #读取输入,将读取到的数据赋值给指定变量 range() #生成一个列表 dir() #查看对象内所有属性及
阅读全文
摘要:import unittestclass TestLegion(unittest.TestCase): def setUp(self): pass def tearDown(self): pass def test_createlegion(self): self.assertEqual(2,1)
阅读全文
摘要:import math #导入math模块 math.floor() #调用math模块中的floor()函数 from math import floor #导入math模块中的floor函数方法 floor() #调用floor()函数
阅读全文
摘要:try: x = int(input('Enter the first number: ')) y = int(input('Enter the second number: ')) print(x/y)except ZeroDivisionError: print("输入的数字不能为0")
阅读全文
摘要:class CocaCola: formula = ['caffeine','sugar','water','soda'] #类的属性coke_for_me = CocaCola() #类的实例化coke_for_you = CocaCola() #类的实例化print(CocaCola.formu
阅读全文
摘要:def account_login(): password = input('Password:') if password == '12345': print('Login success!') else: print('Wrong password or invalid input!') acc
阅读全文
摘要:字典中的数据必须以键值对的形式出现。 键不能重复,而值可以重复。 字典中的键key是不可变的,而值value是可变可修改的,可以是任何对象。 dangan={ 'name':'Lily', 'age':20 } dangan['hobby'] = 'sing' #添加 dangan.update({
阅读全文

浙公网安备 33010602011771号