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]   [1299 views]

Python

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]   [1560 views]

Python

>>> 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]   [1460 views]

Python

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.writeline()
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]   [1665 views]

Python

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]   [2032 views]

Python

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: