Friday, September 5, 2025
HomeLanguagesPython | Numpy np.disp() method

Python | Numpy np.disp() method

With the help of np.disp() method, we can get the string into a display buffer and by using stringIO class we can get the values from buffer by using np.disp() method.

Syntax : np.disp(message, device)
Return : Will not return anything without StringIO class.

Example #1 :
In this example by using np.disp() method, we are able to collect message from parameter and put that message into display buffer by using this method.




# import numpy and stringIO
import numpy as np
from io import StringIO
  
buf = StringIO()
# using np.disp() method
np.disp(u'Geeks For Geeks', device = buf)
buf.getvalue()


Output :

‘Geeks For Geeks\n’

Example #2 :




# import numpy and stringIO
import numpy as np
from io import StringIO
  
buf = StringIO()
# using np.disp() method
np.disp(u'Author "Jitender Kumar"', device = buf)
buf.getvalue()


Output :

‘Author “Jitender Kumar”\n’

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11863 POSTS0 COMMENTS
Shaida Kate Naidoo
6750 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6701 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS