PigRider Blogs

Sign In
HTML CSS Javascript Ruby on Rails C++ Java Python SQL Git Linux Others All
Previous 1 Next

Python glob module

[Author: ming.lian]   [Wed, 2013-08-14, 20:16]   [1809 views]


Python glob is for finding the pathnames matching the pathname pattern accroding to the rules used by the Unix shell.
if you want to grab all the .txt files under C drive, you can do this:
import glob
list = glob.glob(r'c:/*.txt')
print list
and it will return a list that contains all the txt files. ... see full article

Print Beautiful JSON with Python

[Author: ming.lian]   [Mon, 2013-08-12, 20:42]   [2044 views]


>>> import json
>>> print(json.dumps(data))  # No indention
{"status": "OK", "count": 2, "results": [{"age": 27, "name": "Oz", "lactose_intolerant": true}, {"age": 29, "name": "Joe", "lactose_intolerant": false}]}
>>> print(json.dumps(data, indent=2))  # With indention
  "status": "OK",
  "count" ... see full article

Python File Process Common methods

[Author: ming.lian]   [Sun, 2013-08-11, 17:44]   [2063 views]


Open a file:
f = open('filename', 'r')
'r' means read only and if it is 'w', it means write only.
'rb' -> read binary
'wb' -> write binary
'w+' write append
f.write("I am an engineer.")
f.write(str) -> write a string.
f.read() -> read all.
f.read(size) -> the size is the count that how ... see full article

Install Python Module

[Author: xiaotian.li]   [Sun, 2013-08-11, 17:43]   [2101 views]


Here I'm going to introduce 2 ways of installing python module for import.
1. Using easy_install
    Easy Install is a python module (easy_install) bundled with setuptools that lets you automatically download, build, install, and manage Python packages.
Step 1:
Add path to system variables.
Go to "C ... see full article

Install PyDev in Eclipse

[Author: xiaotian.li]   [Sun, 2013-08-11, 17:43]   [2466 views]


First, make sure you have downloaded an appropriate Python version from http://www.python.org/download/
Next are the instructions targeted at Eclipse 3.5 onwards.
1. To install PyDev and PyDev Extensions using the Eclipse Update Manager, 
Go to: Help > Install New Software... menu.
2. In the next sc ... see full article
Previous 1 Next

Most Popular in This Category: