'IT/인터넷 마케팅'에 해당되는 글 14건

  1. 2010.12.07 python Function Description 4
  2. 2010.12.07 log 파일 생성 raw input 6
IT/인터넷 마케팅2010. 12. 7. 19:35
반응형

Function Description
dir([obj]) Display attributes of object or the names of global variables if no parameter given
help([obj]) Display object's documentation string in a pretty-printed format or enters interactive help if no parameter given
int(obj) Convert object to an integer
len(obj) Return length of object
open(fn, mode) Open file fn with mode ('r' = read, 'w' = write)
range([[start, ]stop[,step]) Return a list of integers that begin at start up to but not including stop
                            in increments of step; start defaults to 0, and step defaults to 1
raw_input(str) Wait for text input from the user, optional prompt string can be provided
str(obj) Convert object to a string
type(obj) Return type of object (a type object itself!)

반응형
Posted by Dream Come True
IT/인터넷 마케팅2010. 12. 7. 18:54
반응형
로그파일 생성 간다 팁이다.

import sys
print >> sys.stderr, 'Fatal error: invalid input!'
logfile = open('./mylog.txt', 'a')      #'a' 파일 초기화 하지 않고 지속적으로 update 연산자
print >> logfile, 'Fatal error: invalid input!'
logfile.close()

-rw-rw-rw- 1 park park     56 2010-12-07 18:47 mylog.txt

Fatal error: invalid input!
Fatal error: invalid input!
Fatal error: invalid input!



Raw input
>>> user = raw_input('Enter login name: ')
Enter login name: root
>>> print 'Your login is:', user
Your login is: root


반응형
Posted by Dream Come True