Name | rstyleslice JSON |
Version |
1.4.5
JSON |
| download |
home_page | None |
Summary | 一套符合直觉的索引和切片语法 |
upload_time | 2023-07-14 17:43:09 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.7 |
license | None |
keywords |
rstyleslice
slice
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 项目描述
一套符合直觉的索引和切片语法。
| | **Python** | **rstyleslice** |
| -------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| **索引** | 从 0 开始(0 表示第 1 个元素)<br /><br />-1 表示倒数第 1 个元素(相同点) | 从 1 开始(1 表示第 1 个元素)<br /><br />-1 表示倒数第 1 个元素(相同点) |
| **切片** | 左闭右开区间,例如:<br />[3: 5] 表示提取第 4、5 这 2 个元素 | 双闭区间,例如:<br />[3: 5] 表示提取第 3、4、5 这 3 个元素 |
| **从右往**<br />**左切片** | step(步长)为负值,例如:<br />[9: 1: -1] 表示提取第 9~3 这 7 个元素 | step(步长)始终为正值,例如:<br />[9: 1: 1] 表示提取第 9~1 这 9 个元素 |
切片格式为 [start: stop: step] ,start 表示从哪条开始,stop 表示到哪条停止,step 表示步长。当 step>=2 时表示间隔式切片。
# 关于作者
作者:lcctoor.com
域名:lcctoor.com
邮箱:lcctoor@outlook.com
[主页](https://lcctoor.github.io/me/) \| [微信](https://lcctoor.github.io/me/author/WeChatQR-max.jpg) \| [Python交流群](https://lcctoor.github.io/me/lccpy/WechatReadersGroupQR-original.jpg) \| [捐赠](https://lcctoor.github.io/me/donation/donationQR-1rmb-max.jpg)
# Bug提交、功能提议
您可以通过 [Github-Issues](https://github.com/lcctoor/lccpy/issues)、[微信](https://lcctoor.github.io/me/author/WeChatQR-max.jpg) 与我联系。
# 安装
```
pip install rstyleslice
```
# [教程](https://lcctoor.github.io/lccpy/?doc=rstyleslice)
# 教程预览
#### 导入
```python
from rstyleslice import rslice
```
#### 创建R风格容器
```python
obj = rslice([1,2,3,4,5,6,7,8,9])
# Python中任何可以索引和切片的对象(如list、str、tuple)都可以转化成R风格容器。
```
#### 索引取值
```python
obj[1]
# >>> 1
```
#### 索引赋值
```python
obj[1] = 111
obj[:]
# >>> [111, 2, 3, 4, 5, 6, 7, 8, 9]
```
#### 切片取值
```python
obj[3:7] # >>> [3, 4, 5, 6, 7]
obj[7:3] # >>> [7, 6, 5, 4, 3]
obj[3:7:2] # >>> [3, 5, 7]
obj[8:2:3] # >>> [8, 5, 2]
```
#### 切片赋值
```python
obj[4:6] = [44, 55]
obj[:]
# >>> [111, 2, 3, 44, 55, 7, 8, 9]
obj[4:6] = []
obj[:]
# >>> [111, 2, 3, 8, 9]
obj[4:] = [1, 2, 3, 4, 5]
obj[:]
# >>> [111, 2, 3, 1, 2, 3, 4, 5]
obj[4:100] = ['1', 2, 3, 4, 5]
obj[:]
# >>> [111, 2, 3, '1', 2, 3, 4, 5]
```
Raw data
{
"_id": null,
"home_page": null,
"name": "rstyleslice",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "rstyleslice,slice",
"author": null,
"author_email": "\"lcctoor.com\" <lcctoor@outlook.com>",
"download_url": "https://files.pythonhosted.org/packages/fc/c2/d1399a6d7c9bc61ddc95529c8b5c556a628971a99804a0168161cacbb9f2/rstyleslice-1.4.5.tar.gz",
"platform": null,
"description": "# \u9879\u76ee\u63cf\u8ff0\n\n\u4e00\u5957\u7b26\u5408\u76f4\u89c9\u7684\u7d22\u5f15\u548c\u5207\u7247\u8bed\u6cd5\u3002\n\n| | **Python** | **rstyleslice** |\n| -------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- |\n| **\u7d22\u5f15** | \u4ece 0 \u5f00\u59cb\uff080 \u8868\u793a\u7b2c 1 \u4e2a\u5143\u7d20\uff09<br /><br />-1 \u8868\u793a\u5012\u6570\u7b2c 1 \u4e2a\u5143\u7d20\uff08\u76f8\u540c\u70b9\uff09 | \u4ece 1 \u5f00\u59cb\uff081 \u8868\u793a\u7b2c 1 \u4e2a\u5143\u7d20\uff09<br /><br />-1 \u8868\u793a\u5012\u6570\u7b2c 1 \u4e2a\u5143\u7d20\uff08\u76f8\u540c\u70b9\uff09 |\n| **\u5207\u7247** | \u5de6\u95ed\u53f3\u5f00\u533a\u95f4\uff0c\u4f8b\u5982\uff1a<br />[3: 5] \u8868\u793a\u63d0\u53d6\u7b2c 4\u30015 \u8fd9 2 \u4e2a\u5143\u7d20 | \u53cc\u95ed\u533a\u95f4\uff0c\u4f8b\u5982\uff1a<br />[3: 5] \u8868\u793a\u63d0\u53d6\u7b2c 3\u30014\u30015 \u8fd9 3 \u4e2a\u5143\u7d20 |\n| **\u4ece\u53f3\u5f80**<br />**\u5de6\u5207\u7247** | step\uff08\u6b65\u957f\uff09\u4e3a\u8d1f\u503c\uff0c\u4f8b\u5982\uff1a<br />[9: 1: -1] \u8868\u793a\u63d0\u53d6\u7b2c 9~3 \u8fd9 7 \u4e2a\u5143\u7d20 | step\uff08\u6b65\u957f\uff09\u59cb\u7ec8\u4e3a\u6b63\u503c\uff0c\u4f8b\u5982\uff1a<br />[9: 1: 1] \u8868\u793a\u63d0\u53d6\u7b2c 9~1 \u8fd9 9 \u4e2a\u5143\u7d20 |\n\n\u5207\u7247\u683c\u5f0f\u4e3a [start: stop: step] \uff0cstart \u8868\u793a\u4ece\u54ea\u6761\u5f00\u59cb\uff0cstop \u8868\u793a\u5230\u54ea\u6761\u505c\u6b62\uff0cstep \u8868\u793a\u6b65\u957f\u3002\u5f53 step>=2 \u65f6\u8868\u793a\u95f4\u9694\u5f0f\u5207\u7247\u3002\n\n# \u5173\u4e8e\u4f5c\u8005\n\n\u4f5c\u8005\uff1alcctoor.com\n\n\u57df\u540d\uff1alcctoor.com\n\n\u90ae\u7bb1\uff1alcctoor@outlook.com\n\n[\u4e3b\u9875](https://lcctoor.github.io/me/) \\| [\u5fae\u4fe1](https://lcctoor.github.io/me/author/WeChatQR-max.jpg) \\| [Python\u4ea4\u6d41\u7fa4](https://lcctoor.github.io/me/lccpy/WechatReadersGroupQR-original.jpg) \\| [\u6350\u8d60](https://lcctoor.github.io/me/donation/donationQR-1rmb-max.jpg)\n\n# Bug\u63d0\u4ea4\u3001\u529f\u80fd\u63d0\u8bae\n\n\u60a8\u53ef\u4ee5\u901a\u8fc7 [Github-Issues](https://github.com/lcctoor/lccpy/issues)\u3001[\u5fae\u4fe1](https://lcctoor.github.io/me/author/WeChatQR-max.jpg) \u4e0e\u6211\u8054\u7cfb\u3002\n\n# \u5b89\u88c5\n\n```\npip install rstyleslice\n```\n\n# [\u6559\u7a0b](https://lcctoor.github.io/lccpy/?doc=rstyleslice)\n\n# \u6559\u7a0b\u9884\u89c8\n\n#### \u5bfc\u5165\n\n```python\nfrom rstyleslice import rslice\n```\n\n#### \u521b\u5efaR\u98ce\u683c\u5bb9\u5668\n\n```python\nobj = rslice([1,2,3,4,5,6,7,8,9])\n\n# Python\u4e2d\u4efb\u4f55\u53ef\u4ee5\u7d22\u5f15\u548c\u5207\u7247\u7684\u5bf9\u8c61\uff08\u5982list\u3001str\u3001tuple\uff09\u90fd\u53ef\u4ee5\u8f6c\u5316\u6210R\u98ce\u683c\u5bb9\u5668\u3002\n```\n\n#### \u7d22\u5f15\u53d6\u503c\n\n```python\nobj[1]\n# >>> 1\n```\n\n#### \u7d22\u5f15\u8d4b\u503c\n\n```python\nobj[1] = 111\nobj[:]\n# >>> [111, 2, 3, 4, 5, 6, 7, 8, 9]\n```\n\n#### \u5207\u7247\u53d6\u503c\n\n```python\nobj[3:7] # >>> [3, 4, 5, 6, 7]\nobj[7:3] # >>> [7, 6, 5, 4, 3]\nobj[3:7:2] # >>> [3, 5, 7]\nobj[8:2:3] # >>> [8, 5, 2]\n```\n\n#### \u5207\u7247\u8d4b\u503c\n\n```python\nobj[4:6] = [44, 55]\nobj[:]\n# >>> [111, 2, 3, 44, 55, 7, 8, 9]\n\nobj[4:6] = []\nobj[:]\n# >>> [111, 2, 3, 8, 9]\n\nobj[4:] = [1, 2, 3, 4, 5]\nobj[:]\n# >>> [111, 2, 3, 1, 2, 3, 4, 5]\n\nobj[4:100] = ['1', 2, 3, 4, 5]\nobj[:]\n# >>> [111, 2, 3, '1', 2, 3, 4, 5]\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "\u4e00\u5957\u7b26\u5408\u76f4\u89c9\u7684\u7d22\u5f15\u548c\u5207\u7247\u8bed\u6cd5",
"version": "1.4.5",
"project_urls": {
"HomePage": "https://lcctoor.github.io/lccpy/?package=rstyleslice"
},
"split_keywords": [
"rstyleslice",
"slice"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "e0400cc4336df949f63217b2069b2ee00d442aa1a5a370104e6b51d6f8964910",
"md5": "bfdb2c29b6b692eea1338dc5fc5b2a7d",
"sha256": "49390245e9ca2cfb886db1b41e3c4fd811f095877910f101cfbe86dcbb39f7d8"
},
"downloads": -1,
"filename": "rstyleslice-1.4.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bfdb2c29b6b692eea1338dc5fc5b2a7d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 8668,
"upload_time": "2023-07-14T17:43:07",
"upload_time_iso_8601": "2023-07-14T17:43:07.749017Z",
"url": "https://files.pythonhosted.org/packages/e0/40/0cc4336df949f63217b2069b2ee00d442aa1a5a370104e6b51d6f8964910/rstyleslice-1.4.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "fcc2d1399a6d7c9bc61ddc95529c8b5c556a628971a99804a0168161cacbb9f2",
"md5": "dc0b9976809d52ef4a0217f93037625b",
"sha256": "00fcaa39375e9fa9df38bcf098e6c145fd786d16d8b58a0c85953e88eac7c2f5"
},
"downloads": -1,
"filename": "rstyleslice-1.4.5.tar.gz",
"has_sig": false,
"md5_digest": "dc0b9976809d52ef4a0217f93037625b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 7525,
"upload_time": "2023-07-14T17:43:09",
"upload_time_iso_8601": "2023-07-14T17:43:09.960578Z",
"url": "https://files.pythonhosted.org/packages/fc/c2/d1399a6d7c9bc61ddc95529c8b5c556a628971a99804a0168161cacbb9f2/rstyleslice-1.4.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-14 17:43:09",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "rstyleslice"
}