标签:port turn fir sts 打印 pat cond def inf
class Point:
def __init__(self,x,y):
self.x = x
self.y = y
def move(self):
print("move")
def draw(self):
print("draw")
# 创建一个对象
point1 = Point(10,20)
print(point1.x) #10
class Mammal:
def walk(self):
print("walk")
class Dog(Mammal):
def bark(self):
print("bark")
class Cat(Mammal):
pass
dog = Dog()
dog.bark()
cat = Cat()
cat.walk()
import 模块名
from 模块名 import 函数名
import random
#随机打印一个人的名字
members = [‘John‘,‘Mary‘,‘Bob‘,‘Mosh‘]
leader = random.choice(members)
print(leader)
#打印三个10-30之间的正整数
for i in range(3):
print(random.randint(10,30))
#掷骰子
class Dice:
def roll(self):
first = random.randint(1,6)
second = random.randint(1,6)
return (first,second)
dice = Dice()
print(dice.roll())
from pathlib import Path
#造对象
path = Path("app")
#打印是否有app这个文件夹
print(path.exists())
#创建app文件夹
print(path.mkdir())
#遍历索引xls格式的文件
path1 = Path()
for file in path1.glob(‘*.xls‘):
print(file)
#安装处理表格的 openpyxl包
pip install openpyxl
标签:port turn fir sts 打印 pat cond def inf
原文地址:https://www.cnblogs.com/nnadd/p/12822747.html