python> Get substring> print serial [5:10] / print serial [5: -1]

I want to take a part of the character string

Reference http://www.mwsoft.jp/programming/python/str.html#substring Related http://qiita.com/7of9/items/62051d106c031e0f5b96

https://ideone.com/DpzMwn

serial="123456789012345678901234567890"

print "{0}", serial

print "{0:5>9}", serial

print "{0}", serial[5:10]

print "{0}", serial[5:-1]

result


Success	time: 0.01 memory: 8968 signal:0
{0} 123456789012345678901234567890
{0:5>9} 123456789012345678901234567890
{0} 67890
{0} 678901234567890123456789

Is "{0}" unnecessary before?

I was thinking of using the Pi Zero serial number as a unique number, but I started to think that keeping all the characters was a security issue. If you make it a part of the character string, you can avoid the collision of numbers to some extent, and it seems that you can use it as a unique number.

Recommended Posts

python> Get substring> print serial [5:10] / print serial [5: -1]
[Python] Get environment variables
Serial communication with python
[Python] Get Qiita trends
Python print function (sequel)
[Python3] Get date diff
Get date in Python
Get date with python
python get current time
Get YouTube Comments in Python
Get country code with python
Python --bitflyer Get asset balance
Get last month in python
Get Twitter timeline with python
Get Youtube data with python
Introduction to serial communication [Python]
Get Terminal size in Python
[Python] Get the previous month
Explicitly get EOF in python
Get thread ID with python
Get started with Python! ~ ② Grammar ~
[python] Get quotient and remainder
Get home directory with python
Get keyboard events with python
IfcOpenShell python bindings get started
(Python) Get AWS billing amount
Python --bitflyer Get chat content
Get Alembic information with Python
Python> dictionary> get ()> optional value
Get Japanese synonyms in Python
Get Leap Motion data in Python.
Get started with Python! ~ ① Environment construction ~
Get reviews with python googlemap api
Get the desktop path in Python
Print with python3 without line breaks
Get the weather with Python requests
Get web screen capture with python
Get the weather with Python requests 2
[Python] Get economic data with DataReader
Get the script path in Python
How to get the Python version
How to get started with Python
[Small story] Get timestamp with Python
[Python] Be careful when using print
Get Qiita trends with Python scraping
Get upcoming weather from python weather api
Get the desktop path in Python
Get the host name in Python
Python Note: Get the current month
Python version to get unused ports
Get started with Python in Blender
Get weather information with Python & scraping