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
Iperf是美国伊利诺斯大学(University of Illinois)开发的一种开源的网络性能测试工具。 可以用来测试网络节点间(也包括回环)TCP或UDP连接的性能,包括带宽、抖动以及丢包率, 其中抖动和丢包率适应于UDP测试,而带宽测试适应于TCP和UDP。
TCP支持:
Measure bandwidth
Report MSS/MTU size and observed read sizes.
Support for TCP window size via socket buffers.
Multi-threaded if pthreads or Win32 threads are available. Client and server can have multiple simultaneous connections.
UDP支持:
Client can create UDP streams of specified bandwidth.
Measure packet loss
Measure delay jitter
Multicast capable
Multi-threaded if pthreads are available. Client and server can have multiple simultaneous connections.
所以,服务端通过-u来区分监听协议,而TCP协议不能计算时延与丢包率,而且不能指定发送带宽。
服务端
1
$ iperf3 -s
客户端
1 2
$ iperf3-c IP $ iperf3--client IP--bandwidth 900M--window 1M
需要使用TCP来测试带宽的时候,需要指定TCP的窗口大小,
窗口的大小即网络通道的容量 capacity = bandwidth x round-trip-time
其中round-trip-time可以通过ping来得到。
参数
1 2 3 4 5 6 7 8
-c --client 标记客户端 -i --interval 设定输出值间隔 -u --udp 使用传输协议为UDP -t --time 设定传输时间 -F --file 指定传输文件 -P --parallel 指定进程数 -b --bandwidth 指定带宽 -w --window 指定window大小,For TCP, this sets the TCP window size;For UDP it is just the buffer which data
You are in'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch>
HEAD is now at 99ada87... Merge pull request #89 from schacon/appendix-final
$ git checkout 2.0-beta-0.1 Previous HEAD position was 99ada87... Merge pull request #89 from schacon/appendix-final HEAD is now at df3f601... add atlas.json and cover image