Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

print function args python

# sep
print('a', 'b', 'c', sep='  ')
#>>> a  b  c

# end
print('a', end= ' ')
print('b')
print('c')
#>>> a b
#>>> c

print('a', end= ' ')
print('b', end= '/')
print('c')
#>>> a b/c

# file
import os
os.chdir('{}/Desktop'.format(os.environ.get('userprofile')))

with open('test.txt', 'w') as test:
    print('THIS IS IN THE FILE', file=test)

# flush
import time

for i in reversed(range(1,4)):
  print(i, end='>>>', flush=True)
  time.sleep(1)
print('Start')
#>>> 3>>>{wait}2>>>{wait}1>>>{wait}Start

import time

for i in reversed(range(1,4)):
  print(i, end='>>>', flush=False)
  time.sleep(1)
print('Start')
#>>> 3>>>2>>>1>>>Start
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #print #function #args #python
ADD COMMENT
Topic
Name
4+6 =