Chapter 2
7418 단어 apt
>>> import sys
>>> print >> sys.stderr,'Fatal error!'
Fatal error!
2、raw_input () 내장 함수는 마크업 입력을 읽습니다. 사용자의 입력은 문자열 형식입니다. 정형으로 바뀌어야 합니다.
1 >>> num=raw_input("Enter a num: ")
2 Enter a num: 2341
3 >>> print 'the num is: %d' % int(num)
4 the num is: 2341
3. Python은 C 언어의 자동 증가 1 및 자동 감소 1 작업을 지원하지 않습니다.
더하기 기호(+) 사용자 문자열의 연결 연산, 곱하기 기호(*)는 문자열의 중복에 사용됩니다.
4, 클래스
인스턴스가 생성될 때 __init__() 가 자동으로 호출됩니다.
self.__class__.__name__되돌아오는 것은 이 종류의 클래스 이름이다.
dir()는 Python에서 제공하는 API 함수로, dir() 함수는 자동으로 검색 __를 포함한 객체의 모든 속성을 찾습니다.dict__에 나열된 속성입니다.
>>>dir(FooClass)
>>>['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'showname', 'version']
>>>FooClass.__dict__()
>>>{'__module__': '__main__', 'version': 0.1, 'showname': <function showname at 0x10994e578>, '__dict__': <attribute '__dict__' of 'FooClass' objects>, '__weakref__': <attribute '__weakref__' of 'FooClass' objects>, '__doc__': 'optional documentation string', '__init__': <function __init__ at 0x109945ed8>}
5, 모듈
>>> import sys
>>> sys.platform
'darwin'
>>> sys.version
'2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)]'
>>> sys.stdout.write("Hello dear!
") #write()
Hello dear!
>>> sys.stdout.write("Hello dear!")
Hello dear!>>>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
【TravisCI 개선】sudo apt get install하고 있던 곳을 sudo 사용하지 않게 한다 ~sudo: false로 이용하기 위해서~sudo: false 에서 빌드 돌리면 빠르다는 기사를 잘 보았으므로 실제로 해보면 5분 정도 달랐다. 기동 후의 처리가 빠른 것 같다 60 분이 55 분이면 너무 감동적이지 않을 수도 있지만 15 분이 10 분이면...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.