代码拉取完成,页面将自动刷新
'''
Author: caishuyang
Date: 2023-01-08 14:50:05
LastEditors: caishuyang
LastEditTime: 2023-01-08 16:48:56
Description:
'''
import yaml
class Ball():
def __init__(self, typename):
self.classname = 'Ball'
self.name = typename
self.r = 5e-3
self.m = 1e-3
self.num = 0
self.x = 0
self.y = 0
self.vx = 0
self.vy = 0
self.ax = 0
self.ay = 0
self.readParam()
def readParam(self):
yamlPath = 'config.yaml'
flag = True
try:
f = open(yamlPath, 'r', encoding='utf-8')
except:
print('无法打开', yamlPath)
flag = False
if flag:
cont = f.read()
param = yaml.load(cont, Loader=yaml.FullLoader)
dic = param[self.classname][self.name]
self.r = float(dic['r'])
self.num = float(dic['num'])
self.m = float(dic['m'])
def __str__(self):
return self.name
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。