有人用过带有切角的按钮吗?互联网上有关于如何做到这一点的提示(使用clip-path伪元素)。
但任务很复杂,因为您需要将效果附加到这样的按钮,即hover-e 处的发光。
这是可行的,但由于clip-path发光,它不会向外扩散,并且伪元素很难突出显示。
也许有人已经解决了类似的问题
from dotenv import load_dotenv
import os
from googleapiclient.discovery import build
import json
load_dotenv()
class Channel:
"""Класс для ютуб-канала"""
youtube = build('youtube', 'v3', developerKey=os.getenv("API_YOU_TUBE"))
def __init__(self, channel_id: str) -> None:
"""Экземпляр инициализируется id канала. Дальше все данные будут подтягиваться по API."""
self.__channel_id = channel_id
self.title = self.get_data_init()["items"][0]["snippet"]["title"]
self.description = self.get_data_init()["items"][0]["snippet"]["description"]
self.url = "https://www.youtube.com/channel/" + self.get_data_init()["items"][0]["id"]
self.subscriber_count = self.get_data_init()["items"][0]["statistics"]["subscriberCount"]
self.video_count = self.get_data_init()["items"][0]["statistics"]["videoCount"]
self.view_count = self.get_data_init()["items"][0]["statistics"]["viewCount"]
def print_info(self) -> None:
"""Выводит в консоль информацию о канале."""
channel = self.youtube.channels().list(id=self.__channel_id, part='snippet,statistics').execute()
print(channel)
def get_data_init(self):
channel = self.youtube.channels().list(id=self.__channel_id, part='snippet,statistics').execute()
return channel
@staticmethod
def get_service():
return Channel.youtube
def to_json(self, data):
with open(data, "w") as f:
f.write(str(self.get_data_init()))
def __repr__(self):
return f"{self.__channel_id}, {self.subscriber_count}"
moscowpython = Channel('UC-OVMPlMA3-YCIeg4z5z23A')
moscowpython.__channel_id = 'Новое название'
print(moscowpython.__channel_id)
print(moscowpython)
# не выдает никаких ошибок, хотя должна AttributeError```
Изменено:
вот так выдает ошибку:
moscowpython = Channel('UC-OVMPlMA3-YCIeg4z5z23A')
print(moscowpython.__channel_id)
moscowpython.__channel_id = 'Новое название'
print(moscowpython.__channel_id)
print(moscowpython)
а вот так нет:
moscowpython = Channel('UC-OVMPlMA3-YCIeg4z5z23A')
# print(moscowpython.__channel_id)
moscowpython.__channel_id = 'Новое название'
print(moscowpython.__channel_id)
print(moscowpython)
我将一些 Unity 场景对象保存到 XML 文件中,以便随时加载此状态并继续游戏。保存到文件没有问题,但读取很糟糕 - 代码将 XML 读取到结构中的第一个结束对象,然后完成读取,尽管这还不到整个文件的 1%。这是一个没有组件等的示例文件:
<?xml version="1.0"?>
<ArrayOfSerializableObject xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SerializableObject>
<Name>1</Name>
<Tag></Tag>
<Position></Position>
<Rotation></Rotation>
<Scale></Scale>
<Children>
<SerializableObject>
<Name>2</Name>
<Tag></Tag>
<Position></Position>
<Rotation></Rotation>
<Scale></Scale>
<Children>
<SerializableObject>
<Name>3</Name>
<Tag></Tag>
<Position></Position>
<Rotation></Rotation>
<Scale></Scale>
<Children>
<SerializableObject>
<Name>4</Name>
<Tag></Tag>
<Position></Position>
<Rotation></Rotation>
<Scale></Scale>
<Children />
<Components></Components>
</Children>
<Components></Components>
</SerializableObject>
<SerializableObject>
<Name>5</Name>
<Tag></Tag>
<Position></Position>
<Rotation></Rotation>
<Scale></Scale>
<Children />
<Components></Components>
</SerializableObject>
</Children>
<Components></Components>
</SerializableObject>
</Children>
<Components />
</SerializableObject>
</ArrayOfSerializableObject>
结果,我将收到以下结构中的对象:
-1
--2
---3
----4
5 及以后将不再被读取,因为代码应该到达文件末尾。
事实上,这里是保存和读取代码本身(或者更正确地说,是它的一个片段):
using System.Collections.Generic;
using System;
using System.IO;
using System.Xml.Serialization;
using UnityEngine;
using System.Collections;
[Serializable]
public class SerializableObject
{
public string Name;
public string Tag;
public Vector3 Position;
public Quaternion Rotation;
public Vector3 Scale;
public List<SerializableObject> Children = new List<SerializableObject>();
public List<SerializableComponent> Components = new List<SerializableComponent>();
}
[Serializable]
public class SerializableComponent
{
public string TypeName;
public SerializableDictionary Properties = new SerializableDictionary();
}
[Serializable]
public class SerializableDictionary : IXmlSerializable
{
public Dictionary<string, string> Dictionary = new Dictionary<string, string>();
public System.Xml.Schema.XmlSchema GetSchema()
{
return null;
}
public void ReadXml(System.Xml.XmlReader reader)
{
reader.Read();
while(reader.NodeType != System.Xml.XmlNodeType.EndElement)
{
string key = reader.GetAttribute("Key");
string value = reader.GetAttribute("Value");
Dictionary.Add(key, value);
reader.Read();
}
reader.ReadEndElement();
}
public void WriteXml(System.Xml.XmlWriter writer)
{
foreach(var kvp in Dictionary)
{
writer.WriteStartElement("Item");
writer.WriteAttributeString("Key", kvp.Key);
writer.WriteAttributeString("Value", kvp.Value);
writer.WriteEndElement();
}
}
}
public class SaveLoadManager : MonoBehaviour
{
public Transform rootObject;
public string path, sceneName;
private List<SerializableObject> loadedData;
void Awake()
{
#if UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX
path = System.IO.Path.GetFullPath(System.IO.Path.Combine(Application.dataPath, "..", "..", "Files", "Saves", sceneName, "savefile.xml"));
#else
string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
path = System.IO.Path.GetFullPath(System.IO.Path.Combine(documentsPath, "MTS", "Files", "Saves", sceneName, "savefile.xml"));
#endif
}
// Сохранение
public void SaveToXML()
{
List<SerializableObject> data = new List<SerializableObject>();
foreach(Transform child in rootObject)
{
data.Add(SaveObject(child));
}
XmlSerializer serializer = new XmlSerializer(typeof(List<SerializableObject>));
using(FileStream stream = new FileStream(path, FileMode.Create))
{
serializer.Serialize(stream, data);
}
}
private SerializableObject SaveObject(Transform obj)
{
SerializableObject serializableObject = new SerializableObject
{
Name = obj.name,
Tag = obj.tag,
Position = obj.localPosition,
Rotation = obj.localRotation,
Scale = obj.localScale
};
foreach(Component component in obj.GetComponents<Component>())
{
if(component.GetType() != typeof(Transform))
{
serializableObject.Components.Add(SaveComponent(component));
}
}
foreach(Transform child in obj)
{
serializableObject.Children.Add(SaveObject(child));
}
return serializableObject;
}
private SerializableComponent SaveComponent(Component component)
{
SerializableComponent serializableComponent = new SerializableComponent
{
TypeName = component.GetType().AssemblyQualifiedName
};
foreach(var field in component.GetType().GetFields())
{
if(field.IsPublic)
{
serializableComponent.Properties.Dictionary[field.Name] = field.GetValue(component)?.ToString();
}
}
return serializableComponent;
}
// Загрузка
public void LoadFromXML()
{
XmlSerializer serializer = new XmlSerializer(typeof(List<SerializableObject>));
using(FileStream stream = new FileStream(path, FileMode.Open))
{
loadedData = (List<SerializableObject>)serializer.Deserialize(stream);
}
foreach(Transform child in rootObject)
{
Destroy(child.gameObject);
}
foreach(var data in loadedData)
{
LoadObject(data, rootObject);
}
}
private void LoadObject(SerializableObject data, Transform parent)
{
GameObject obj = new GameObject(data.Name);
obj.tag = data.Tag;
obj.transform.SetParent(parent);
obj.transform.localPosition = data.Position;
obj.transform.localRotation = data.Rotation;
obj.transform.localScale = data.Scale;
foreach(var childData in data.Children)
{
LoadObject(childData, obj.transform);
}
}
}
(venv) damir@damir-WARD-H202:~/Desktop/electronics-shop-project-main$ python3 homework-1/main.py
Traceback (most recent call last):
File "/home/damir/Desktop/electronics-shop-project-main/homework-1/main.py", line 1, in <module>
from src.item import Item
ModuleNotFoundError: No module named 'src'
├── homework-1
│ ├── main.py
│ └── README.md
├── homework-2
│ ├── main.py
│ └── README.md
├── homework-3
│ ├── main.py
│ └── README.md
├── homework-4
│ ├── main.py
│ └── README.md
├── homework-5
│ ├── main.py
│ └── README.md
├── homework-6
│ ├── main.py
│ └── README.md
├── pyproject.toml
├── README.md
├── src
│ ├── __init__.py
│ ├── item.py
│ └── items.csv
└── tests
├── __init__.py
└── test_item.py
目前,我的目标是培训成为一名 ASP.NET Core 开发人员(之前我学习过 .NET Framework,但决定改变我的计划)。关键问题是我是否需要学习.NET 平台本身,据我所知,ASP.NET 是基于该平台的。如果是这样,怎么办? Jeffrey Richter 的书“CLR via C#”是为 .NET Framework 编写的,但我还没有找到任何类似的针对 .NET 的书。在开源中我没有找到任何用 C# 编写 .NET 项目的手册。