20211218

20211218

hmao

20211218

发布于:2021-12-18 17:21:02
别名:20211218

[code]
# coding:utf-8
‘’’
————————————————————————
fruits=[‘apple’,’banana’,’pear’,’orange’]
index=0
while index<len(fruits):
print(fruits[index])
index +=1
————————————————————————
for i in fruits:
print(1)
————————————————————————
n=[1,2,3,4,5,6]
for i in n:
print(i6)
————————————————————————
heroes=[‘提莫队长’,’蛮族之王’,’战争女神’,’疾风剑豪’]
for heroes in n:
print(i
4)
————————————————————————
#用列表存储cf神奇对象
————————————————————————
1.单词
————————————————————————
gun枪
price
————————————————————————
2.代码部分
————————————————————————
class Gun():
def init(self,name,type,price):
self.name=name
self.type=type
self.price=price

guns=[Gun('修罗','服务器','666'),Gun('激光','狙击枪','999'),Gun('青龙','突击步枪','888')]
for gun in guns:
    print(gun.name+'是'+gun.type+'价格为:'+gun.price)
------------------------------------------------------------------------
class Gun():
    def __init__(self,name,type,price):
        self.name=name
        self.type=type
        self.price=price

guns=[Gun('修罗','服务器','666'),Gun('激光','狙击枪','999'),Gun('青龙','突击步枪','888')]
for gun in guns:
    print(gun.name+'是'+gun.type+'价格为:'+gun.price)
-------------------------------------------------------------------
price=[23,43,18,77]
for i in price:
    if i < 30:
        print(i)
-------------------------------------------------------------------
'''
class Dog():
    def __init__(self,name):
        self.name=name

dogs=[Dog('二哈'),Dog('金毛'),Dog('泰迪')]
for dog in dogs:
    print(dog.name)

[/code]


💬 评论

111111 · 2021-12-30 18:02

111111

  • 标题: 20211218
  • 作者: hmao
  • 创建于 : 2021-12-18 17:21:02
  • 更新于 : 2026-08-19 14:26:00
  • 链接: https://blog.imce.cn/20211218/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论