print 'kkkjjjsss'[6:8]
print chr(65)
print ord('@')
import datetime
print datetime.datetime.now()
import time
time.sleep (2.5)
a = [33,44,444]
print len(a)
- Determines whether the array is empty.
a = [33,44,444]
print not a
If false is returned, it is not null, and true is returned, it is null.
- Add something to the end of the array or the member at the end of the pop-up window (if an array is added to the array, it is different from extend, and the entire array is put at the end of the array by an element of course)
a = [33,44,444]
a.append('c')
print a
a.pop()
print a
- Insert c into the 3rd Members of the array, delete the 3rd Members, and set the sequence to 0.
a = [33,44,444]
a.insert(2,'c')
print a
a.pop(2)
print a
- Append an array to the end of the array (if an array is added to an array, different from append, the array is split into members and added to the end of the array one by one)
a = [33,44,444]
r = a + ['c']
print r
r.extend(['ruby','watir'])
print r
a = [33,44,444]
for i in a:
print i
Note: for in is followed by a colon, indentation, and wordy.
- Retrieve the hash key value and value
a = [33,44,444]
for i,s in enumerate(a):
print "index:" + str(i)
print "value:" + str(s)
Note: Non-string addition must be forcibly converted to string first, OK
a = [33,44,444,44]
a = list(set(a))
print a
Check whether the array contains certain elements
a = [33,44,444,44]
print 33 in a
If you want linux to recognize that the source code is python, add this sentence in the first line of the file,
#! /usr/bin/env python
If you do not want to use python xxx. py to execute your source code, you can assign the source File Execution attributes.
chmod +x myscript.py
Run./xxx. py again.
If you want to write Chinese characters in your python source file, add this sentence in the first line of the file. If you want to add #! /Usr/bin/env python. It's okay to add it to the second line.
# -*- coding: UTF-8 -*-