python基础
七七高7777
这个作者很懒,什么都没留下…
展开
-
Python基础学习-14
Python基础学习-14# Python timeimport datetimeimport json# outputx = datetime.datetime.now()print(x)y = x.yearprint(y, x.strftime("%A"))# create datetime objectx = datetime.datetime(2021, 8, 25)print(x)print(x.strftime("%B"))# Python jsonx =原创 2021-12-02 20:48:52 · 566 阅读 · 0 评论 -
Python基础学习-13
Python基础学习-13# Python 继承# create 父类class Person: def __init__(self, fname, lname): self.first_name = fname self.last_name = lname def print_name(self): print(self.first_name, self.last_name)x = Person("猪猪侠", "GGBang")原创 2021-12-01 20:06:41 · 3290 阅读 · 0 评论 -
Python基础学习-12
Python基础学习-12# Classes and objects# use class key to create the classclass My_Class: x = 6print(My_Class)# create the object p1p1 = My_Class()print(p1.x)# init()函数、所有类都有该内置函数# 使用init()函数为对象属性赋值、# 或在创建对象时需要执行的其他操作class Person: def原创 2021-11-30 16:05:44 · 617 阅读 · 0 评论 -
Python基础学习-11
Python基础学习-11# Python functions# use def keydef my_function(): print("hello from a function")my_function()def name(user): print(user + "没对象")name("小松鼠")name("大灰狼")def girlfriend(boy, girl): print(boy + "的女朋友是" + girl)girlfriend("小原创 2021-11-29 18:18:58 · 246 阅读 · 0 评论 -
Python基础学习-10
Python基础学习-10# if elsea = 1b = 2print(a == b)print(a != b)print(a < b)print(a <= b)print(a > b)print(a >= b)# If retracta = 33b = 200if b > a: print("b 大于 a")a = 33b = 33if b > a: print("b 大于 a")elif a == b:原创 2021-11-28 23:39:01 · 458 阅读 · 0 评论 -
Python基础学习-09
Python基础学习-09# Python dictdictionary = { "name": "Jone", "age": 15, "numbers": "138123456"}print(dictionary)# 字典是有序的、可变的,并且不允许重复。字典项以键值对的形式呈现,可以使用键名进行引用print(dictionary["name"])# 字典内的重复值将覆盖现有值# the dict lenprint(len(dictionary))# 字典内原创 2021-11-27 20:13:39 · 384 阅读 · 0 评论 -
Python基础学习-08
Python基础学习-08# Python gathermy_set = {"小呆呆", "小菲菲", "小羊羊"}print(my_set)# The set is unorderedfor i in my_set: print(i)print("超人强" in my_set)# set addmy_set_1 = {"小呆呆", "小菲菲", "小羊羊", "迷糊老师"}my_set.update(my_set_1)print(my_set)# 因为集合是不能重复的,所以相原创 2021-11-26 20:53:35 · 506 阅读 · 0 评论 -
Python基础学习-07
Python基础学习-07# Python Tuple# Tuples are ordered and immutablemy_tuple = ("一号", "二号", "三号")print(my_tuple)# recursivemy_tuple = ("一号", "二号", "三号", '一号')print(my_tuple)my_tuple = ("一号", "二号", "三号")print(my_tuple[0])# tuple lengthmy_tuple = ("一号",原创 2021-11-25 20:01:19 · 95 阅读 · 0 评论 -
python基础学习-01
python基础学习缩进、注释、变量定义、变量类型、与变量命名、函数基础原创 2021-11-20 20:46:46 · 312 阅读 · 0 评论 -
python基础学习-02
# The python data types"""文本类型: str数字类型: int,float,complex序列类型:list,tuple,range映射类型:dict套装类型:set,frozenset布尔类型:bool二进制类型:bytes,bytearray,memoryview"""# How to get the data type?x = 6print(type(x))# Setting the data type# str字符串x = "This原创 2021-11-21 20:11:36 · 329 阅读 · 0 评论 -
python基础学习-03
python基础-03# Python number# Python There are three types of numbers"""intfloatcomplex"""x = 1 # inty = 2.8 # floatz = 1j # complex# If you want to verify the type of a variable,you can use the type() functionprint(type(x))print(type(y)原创 2021-11-22 18:25:11 · 259 阅读 · 0 评论 -
Python基础学习-04
Python基础学习-04# Python specifying variable types# int() 从整数文字、浮点文字(Delete decimals)或字符串文字(提供字符串表示整数)构造整数# float() 从整数文字、浮点文字或字符串文字构造浮点数(提供字符串表示浮点数或整数)# str() 从多种数据类型构造一个字符串,包括字符串、整理文字和浮点文字# intx = int(1) # x will be 1y = int(2.8) # y will be 2z原创 2021-11-23 13:05:46 · 217 阅读 · 0 评论 -
Python基础学习-05
Python基础学习-05# Python bool# compareprint(10 > 9)print(10 == 9)print(10 < 9)a = 100b = 30if b > a: print("b大于a")else: print("b不大于a")# assessed valueprint(bool("喜羊羊"))print(bool(20))x = "灰太狼"y = "15"print(bool(x))print(boo原创 2021-11-24 20:45:19 · 306 阅读 · 0 评论 -
Python基础学习-06
Python基础学习-06# Python operator# arithmetic# + -a=2b=3c=a-bd=a-bprint(c,d)# * /a=(50-5*6)/4print(a)a=8/5print(a)# mod'''/返回为float,//返回整数,%返回余数'''a=17/3print(a)a=17//3print(a)a=5*3+2print(a)# **'''幂运算 **'''# a=4**2# b=2**3# print(a原创 2021-11-24 20:51:59 · 327 阅读 · 0 评论