测试积点老人 发表于 2019-1-10 16:29:17

python3.x ---print

socket$ python3.4
Python 3.4.3 (default, Oct 14 2015, 20:28:29)
on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print()>>> s='1a'
>>> l=
>>> print(s, l)
1a
>>> print(s, l, sep='')
1a
>>> print(s, l, sep=',')
1a,
>>> print(s, l, sep=',',end='')
1a,>>>
>>> print(s, l, sep=',',end='\n')
1a,
>>>
Help on built-in function print in module builtins:

>>> print(s, l, sep=',', file=open('t.txt', 'w'))
>>> with open(t.txt) as f:>>> f = open('t.txt')
>>> f
<_io.TextIOWrapper name='t.txt' mode='r' encoding='UTF-8'>
>>> f.readlines()
['1a,\n']
>>>
print(...)
    print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
   
    Prints the values to a stream, or to sys.stdout by default.
    Optional keyword arguments:
    file:a file-like object (stream); defaults to the current sys.stdout.
    sep:   string inserted between values, default a space.
    end:   string appended after the last value, default a newline.
    flush: whether to forcibly flush the stream.
(END)

Miss_love 发表于 2021-1-5 13:38:05

支持分享
页: [1]
查看完整版本: python3.x ---print