51Testing软件测试论坛

标题: python3.x ---print [打印本页]

作者: 测试积点老人    时间: 2019-1-10 16:29
标题: python3.x ---print

socket$ python3.4
Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print()

>>> s='1a'
>>> l=[12]
>>> print(s, l)
1a [12]
>>> print(s, l, sep='')
1a[12]
>>> print(s, l, sep=',')
1a,[12]
>>> print(s, l, sep=',',end='')
1a,[12]>>>
>>> print(s, l, sep=',',end='\n')
1a,[12]
>>>


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,[12]\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
支持分享




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2