[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/Lovepython015/Python/master/Article/PythonBasis/python12/2.md [Back]  [Original]

#  `type()`  #



Python 

****

 `type()` 


 `hello.py`  Hello  class 

```python
class Hello(object):
    def hello(self, name='Py'):
        print('Hello,', name)
```

 hello 

 `type()` 

```python
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-

from com.twowater.hello import Hello

h = Hello()
h.hello()

print(type(Hello))
print(type(h))

```



```
Hello, Py


```

`type()` `Hello`  `class`  `type`  `h`  `com.twowater.hello.Hello`

 `com.twowater` `hello` 

 `type()` 

 `Hello` class  `` 

** 	`type()` **

class  class  `type()` 

 `type()`  `Hello` 

```python
# -*- coding: UTF-8 -*-

def printHello(self, name='Py'):
    #  Hello 
    print('Hello,', name)


#  Hello 
Hello = type('Hello', (object,), dict(hello=printHello))

#  Hello 
h = Hello()
#  Hello 
h.hello()
#  Hello class 
print(type(Hello))
#  h 
print(type(h))

```



```
Hello, Py


```

 `type()`  class 

1class  `Hello`

2 Python tuple  object  tuple  `(object,)`

3class  `printHello`  `hello` 



```python
type(, )
```

 `type()`  class 

Python  class  class  `type()`  class 

 `class ***...`  `type()` 



** Python **

 class  Python  


Web Proxy Viewer  |  New URL  |  Original Page