我真的很喜欢可以看出该文件夹结构在这里有一个前端做出反应和处理时,一些后端与快递:
root
??? backend
| ??? node_modules
| ??? public
| ??? src
? ? ??? Server.ts
| ??? package.json
| ??? tsconfig.json
??? frontend (created using create-react-app)
| ??? node_modules
| ??? public
| ??? src
? ? ??? Index.js
| ??? package.json
| ??? tsconfig.json
Run Code Online (Sandbox Code Playgroud)
我认为将单独的包与个人分开node_modules
是合理的,因为前端和后端基本上是完全不同的东西,例如它们需要不同的节点模块。此外,这种模块化方法在视觉上对我很有吸引力,并且存储库看起来很整洁。
但是,当我需要在前端和后端之间共享内容时,我遇到了这种结构的问题。我shared
在项目根目录下添加了一个文件夹,该文件夹包含自己的项目和自己的tsconfig.json
,package.json
等等。这种方法是here和here方法的混合。对于后端,这完全正常:设置了tsconfig.json
适当的(使用TypeScript 项目引用和别名导入),我可以root/shared/src/myFile.ts
像这样引用文件:
root
??? backend
| ??? node_modules
| ??? …
Run Code Online (Sandbox Code Playgroud) 给定公司电子邮件和相应的密码,我需要以编程方式登录login.microsoftonline.com
并访问 Office 365 仪表板 ( office.com
)。该图显示了我尝试找出相应端点的用户流程。
这就是我发现的有关端点的名称和方式的信息。请注意,如果您不使用公司帐户,端点可能会有所不同。
假设:
login.microsoftonline.com
按照重定向进行操作。生成的 HTML 包含一个封装在//<![CDATA[
和中的配置 json 对象//]]>
。搜索"sFT":
并复制该值。搜索"sCtx":
并复制该值。搜索"canary":
并复制该值。搜索"sessionId":
并复制该值。
https://login.microsoftonline.com/common/GetCredentialType?mkt=en-US
我认为这个终点不是必需的。我仍然把它放在这里。
发送 JSON 正文如下:
{
"username": "<your-company-email>",
"flowToken": "<your-sFT-token>"
}
Run Code Online (Sandbox Code Playgroud)
https://login.microsoftonline.com/common/login
作为正文中的表单数据发送:
login:<your-company-email>
passwd:<your-password>
flowToken:<your-sFT-token>
type:11
ctx:<your-sCtx-token>
canary:<your-canary-token>
hpgrequestid:<your-session-id>
Run Code Online (Sandbox Code Playgroud)
https://login.microsoftonline.com/kmsi
“kmsi”代表“让我保持登录状态”。如果您不使用公司邮件登录,则这可能是不会被调用的端点。
作为正文中的表单数据发送:
LoginOptions:3
type:28
ctx:<your-sCtx-token>
flowToken:<your-sFT-token>
canary:<your-canary-token>
hpgrequestid:<your-session-id>
Run Code Online (Sandbox Code Playgroud)
按照此处显示的顺序调用这些端点,我能够成功检索这些 cookie:
来自login.microsoftonline.com
(10 块饼干):
authentication reverse-engineering ms-office single-sign-on office365
给定一个我想使用类型提示增强的函数(在 Python 3.9 中):
def my_func():
return my_dict.keys() # origin of my_dict is irrelevant
Run Code Online (Sandbox Code Playgroud)
我看过PEP 589和这个 Stack Overflow 问题,描述了如何使用TypedDict
. 然而,这不是我试图实现的目标。
我想要字典键对象的返回类型。我知道可以使用将键对象转换为列表list(my_dict)
,然后使用返回类型list[key_type]
(使用key_type
beingint
等str
)。但这是要走的路吗?
my_dict
>>> type(my_dict.keys())
<class 'dict_keys'>
Run Code Online (Sandbox Code Playgroud)
但是,我无法dict_keys
像这样使用:
def my_func() -> dict_keys:
return my_dict.keys()
Run Code Online (Sandbox Code Playgroud)
Pylance 报告说,该my_dict.keys()
类型属于_dict_keys[key_type, value_type]
。为什么这种类型应该是“私有的”?它来自哪里?我们可以以某种方式使用它作为返回类型吗?
给定一个简单的向量向量,我可以利用实现该特征的usize
事实,因此使用格式化程序来漂亮地打印它(请参阅游乐场):Vec
Debug
{:?}
let mut hierarchy: Vec<Vec<usize>> = Vec::new();
hierarchy.push(vec![0,1,2,3]);
hierarchy.push(vec![0,1]);
println!("Hierarchy: {:?}", hierarchy);
Run Code Online (Sandbox Code Playgroud)
假设我将 的输出写入println!(...)
文件。以后如何轻松反序列化它?
例如我的文件如下所示:
[[0,1,2,3],[0,1]]
Run Code Online (Sandbox Code Playgroud)
使用serde
,我可以序列化我的数据类型并将其存储为(例如)JSON 文件。但是,我不需要任何“花哨”的数据格式,只需要这种简单的向量向量。是否有任何简单的解决方案可以根据Debug
特征进行反序列化(“反转打印”)?是否有比手动执行所有解析器逻辑更简单的选择,例如逐字符读取文件以查找[
,]
和,
?