-
Notifications
You must be signed in to change notification settings - Fork 1
Python Code Snippets
WBowam edited this page Apr 3, 2015
·
6 revisions
Date: 2015-03-30
Title: 代码片段
Tags: Snippets, Python
Category: IT
import logging
logging.basicConfig(filename = os.path.join(os.getcwd(), 'log.txt'), level = logging.DEBUG)
logging.debug('this is a message')
f = open("test.txt")
for i, l in enumerate(f):
print i
import sys
source_file = sys.argv[1]
if __name__ == "__main__":
my_func(source_file)
f = open(file, "a") ## a meaning append
f = open(file, "w") ## w meaning write
import re
pattern = re.compile("[a-zA-Z]")
result = pattern.search("adsfuhefdfkj435")
print result.group()
import urllib
urllib.urlretrieve(audio_url, "name.mp3")
easy_install -U pip