You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.2 KiB
89 lines
2.2 KiB
--- |
|
title: 零碎的小问题 |
|
date: 2020-08-16 17:40:28 |
|
updated: 2022-8-26 13:50:01 |
|
tags: |
|
categories: 错误本 |
|
keywords: |
|
description: |
|
top_img: |
|
comments: |
|
cover: |
|
toc: |
|
toc_number: |
|
toc_style_simple: |
|
copyright: |
|
copyright_author: |
|
copyright_author_href: |
|
copyright_url: |
|
copyright_info: |
|
mathjax: |
|
katex: |
|
highlight_shrink: |
|
aside: |
|
--- |
|
|
|
> 所有问题按`想起来/遇到`的顺序排列 |
|
|
|
### 1. python中的__future__包 |
|
|
|
__future__是py2的概念,对应于py2,py3就是future,这是为了在是py2的时候还能用到一些新版本的特性而做成的包。意思禁用py2的import特性改成用py3的import的特性。 |
|
|
|
- from future import absolute_import的作用: |
|
这是相对引用和绝对引用的概念,从相对导入变成绝对导入,大概意指你每次用import X时候都是在sys.path(即python的搜索模块的路径集)里面找X包。只要知道py3的import用法,加上这句话py2时候也能按照py3的import语法去正常使用。 |
|
|
|
- from future import division的作用: |
|
division(精确除法),当我们没有在程序中导入该特征时,"/"操作符执行的是截断除法(Truncating Division), 当我们导入精确除法之后,"/"执行的是精确除法,如下所示: |
|
|
|
```python |
|
>>> 3/4 |
|
0 |
|
>>> from __future__ import division |
|
>>> 3/4 |
|
0.75 |
|
|
|
# 导入精确除法后,若要执行截断除法,可以使用"//"操作符: |
|
>>> 3//4 |
|
0 |
|
>>> |
|
``` |
|
|
|
- from future import print_function的用法: |
|
超前使用python3的print函数。 |
|
|
|
```python |
|
# 在python2.x的环境是使用下面语句 |
|
from __future__ import print_function |
|
print('you are good') # 语法检查通过 |
|
print 'you are good' # 语法检查失败 |
|
``` |
|
|
|
### 2. latex中画文本框 |
|
|
|
这里有个示例: |
|
|
|
```tex |
|
\begin{center} |
|
\fbox |
|
{\parbox{0.92\columnwidth}{ |
|
\subsection*{Key Points}\label{key point} |
|
\begin{center} |
|
\begin{itemize}[left] |
|
\item 1 |
|
|
|
\item 2 |
|
|
|
\item 3 |
|
|
|
\item 4 |
|
|
|
\item 5 |
|
\end{itemize} |
|
\end{center}}} |
|
\end{center} |
|
``` |
|
|
|
渲染结果: |
|
![9c339c404403990ef81c799e78bd85fccf1095a564cf807b32f55d0435569435.png](https://imgs-1302910354.cos.ap-shanghai.myqcloud.com/images/9c339c404403990ef81c799e78bd85fccf1095a564cf807b32f55d0435569435.png) |
|
|
|
>未完待续
|
|
|