print(" hello world ")print()print是系统内置的一个函数
print(print) # print就是一个函数 def myfunc(): pass def func2(p2, p2): passdef :定义函数关键字
myfunc:函数名
fun2(p2,p2): 函数func2有两个参数p1,p2
def print(self, *args, sep=' ', end='
', file=None): # known special case of print """ print(value, ..., sep=' ', end='
', 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. """ pass """ print(value, ..., sep=' ', end='
', 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. """sep: string inserted between values, default a space.
print("hello","world") # hello worldprint("a","b","c",1,[2],True,False)# a b c 1 [2] True Falseend: string appended after the last value, default a newline.
print("
")print("abc",end="") #换行符号为空,不会产生新行。因此abcdef为一行输出print("def")#abcdefsep: string inserted between values, default a space.
print('hello', 'world', sep='
') # 这时hello world会分成两行输出helloworldprint('hello', 'world', sep=' -----')hello -----worldprint('/home', 'user', 'documents', sep='/') # /home/user/documentsprint('', 'home', 'user', 'documents', sep='/') # /home/user/documentsprint(1, 'Python Tricks', 'Dan Bader', sep=',') # node -> child -> childprint('node', 'child', 'child', sep=' -> ') # 1,Python Tricks,Dan Baderimport timenum_seconds = 3for countdown in reversed(range(num_seconds + 1)): if countdown > 0: print(countdown, end='...') time.sleep(1) else: print('Go!')print( "aaa" + str(1))print("abc",1 ) #即可 | 留言与评论(共有 0 条评论) “” |