withopen("README.md", "r") as fh: long_description = fh.read()
setuptools.setup( name="example-pkg-YOUR-USERNAME-HERE", # Replace with your own username version="0.0.1", author="Example Author", author_email="author@example.com", description="A small example package", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/pypa/sampleproject", packages=setuptools.find_packages(), classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ], python_requires='>=3.6', )
setup() 的几个最必须的参数如下所示:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
nameis the distribution nameof your package. This can be anynameas long asonly contains letters, numbers, _ , and -. It also must not already be taken on pypi.org. Be sure toupdate this with your username, as this ensures you won’t try to upload a package with the same nameas one which already existswhen you upload the package.
versionis the package version see PEP 440for more details on versions.
author and author_email are used to identify the author of the package.
description is a short, one-sentence summaryof the package.
long_description is a detailed description of the package. This is shown on the package detail package on the Python Package Index. In this case, the long description is loaded from README.md which is a common pattern.
long_description_content_type tells the index what typeof markup is used for the long description. In this case, it’s Markdown.
url is the URL for the homepage of the project. For many projects, this will just be a link to GitHub, GitLab, Bitbucket, orsimilar code hosting service.
packages is a list ofall Python import packages that should be included in the distribution package. Insteadof listing each package manually, we can use find_packages() to automatically discover all packages and subpackages. In this case, the list of packages will be example_pkg as that’s the only package present.
classifiers gives the indexand pip some additional metadata about your package. In this case, the package isonly compatible with Python 3, is licensed under the MIT license, andis OS-independent. You should alwaysinclude at least which version(s) of Python your package works on, which license your package is available under, and which operating systems your package will workon. For a complete list of classifiers, see https://pypi.org/classifiers/.
创建README.md
创建 README.md ,写上你准备写入的内容:
1 2 3 4 5
# Example Package
Thisis a simple example package. You can use [Github-flavored Markdown](https://guides.github.com/features/mastering-markdown/) to write your content.
创建LICENSE
比如使用MIT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Copyright (c) 2018 The Python Packaging Authority
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
for student in students: print('%(name)s is %(age)d years old' % student)
输出结果如下所示:
1 2 3 4 5 6 7 8 9 10 11 12
1234 => hex => 4d2 1234 => hex => 4D2 1234 => hex => 0x4d2 1234 => hex => 0X4D2 value f is 3.141593 value f is 3.1416 name: Han Meimei, age: 17 name: Li Lei , age: 18 name: Li Lei, age: 0000000018 Han Meimei is 17 years old Li Lei is 18 years old Wei Hua is 17 years old
字符串模板
示例如下:
1 2 3 4 5 6 7
from string import Template
s = Template('Hi, $name! $name is $age years old.') print(s.substitute(name='Han Meimei', age='17'))
print('{0} is {1} years old.'.format('lily', 18)) print('{} is {} years old.'.format('lily', 18)) print('Hi {0}. {0} is {1} years old.'.format('lily', 18))
# 关键字参数 print('{name} is {age} years old'.format(name='lily', age=18))
# 下标参数 lily = ['lily', 18] print('{0[0]} is {0[1]} years old'.format(lily))
lily is 18 years old. lily is 18 years old. Hi lily. lily is 18 years old. lily is 18 years old lily is 18 years old 3.14 3.14 3.14 00003.14 aaaa3.14 3.1416 00003.1416 1100 12 14 c 0xc 0XC 1,230,000,000
I wanted to try Intel Integrated Performance Primitives (IPP) with OpenCV. I installed IPP with these steps:
Intel IPP can be downloaded from here. If you are using it for non-commercial purposes, you can get it for free through Intel’s Non-Commercial Software Development webpage. You need to register with an email address. You will be sent an email with the download link and a registration key.
Download the Intel IPP version you want, beware that its a huge download. I downloaded Intel IPP 7.1, which ships as a 777MB .tgz file.
Unzip the downloaded .tgz file. Run the install.sh file. You will be asked to enter your registration key.
The installer walks you through the steps of installing IPP. I was asked to install the gcc-multilib package, before I could proceed. So, I did:
1
$ sudo apt-get install gcc-multilib
By default, the IPP files are installed to /opt/intel/
Going by the steps given on the Intel website, you are supposed to run the ippvars.sh script, which is in the /opt/intel/ipp/bin directory. It sets the following environment variables: IPPROOT, LIBRARY_PATH and LD_LIBRARY_PATH. This script failed to work for me. So, I set those manually in my .bashrc:
1 2 3 4
# My .bashrc export IPPROOT=/opt/intel/composer_xe_2013.1.117/ipp export LIBRARY_PATH=$LIBRARY_PATH:/opt/intel/composer_xe_2013.1.117/ipp/lib/intel64:/opt/intel/composer_xe_2013.1.117/compiler/lib/intel64 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/intel/composer_xe_2013.1.117/ipp/lib/intel64:/opt/intel/composer_xe_2013.1.117/compiler/lib/intel64