Category:Python
Sub-category
Basic
Command | description | example | Header text |
---|---|---|---|
comment | # for line, """ and """ for paragraph | Example | Example |
Example | print("234") # print string; print 234 # print variable | Example | |
linux bash run | #! /usr/bin/python | Example | Example |
Example | Example | Example | Example |
file operation
myfile = open('/srv/www/idehe.com/stock/data.txt', 'w')
myfile.writelines('\n')
myfile.close()
myfile = open('/srv/www/idehe.com/stock/data.txt', 'a') # open for output (creates)
myfile.writelines('\n')
myfile.writelines(line1) # write a line of text
myfile.writelines('\n')
myfile.writelines(line2) # write a line of text
myfile.close()
Operation
not is evaluated first; and is evaluated next; or is evaluated last.
Group, List, Dict
- group = (), list = [], dict = {}
List
- L[2] 'SPAM!' read the third element
- L[-2] 'Spam' red the last third element
- L[1:] ['Spam', 'SPAM!'] cut the list from the second element
Pratical Test
- for loop
for x in range (xxx, 0, -1):
Project
install/unstall a library, first install pip: apt-get install python-pip
pip install datetime pip uninstall datetime
common used library
- Datetime
- Django
Kivy
For android
- install debian jessie, install python-kivy, python-pip
- install buildozer (pip install), java SDK (default-jdk), cython, etc
- buildozer init, and run: buildozer set default android_new debug deploy run, android USB debug should turn on
- buildozer need ANT, SDK, NDK on first time
Other
Reference
Python
For Raspberry Pi
SPIDEV
- sudo apt-get install python-dev
Image sudo apt-get install python-imaging
Subcategories
This category has the following 3 subcategories, out of 3 total.
Pages in category "Python"
The following 13 pages are in this category, out of 13 total.