In Python print () function does not wrap method

First, let the print () function does not wrap

  In Python, print () function is for the default line. However, in many cases, we do not need to wrap output (such as in the algorithm contest). So, in Python how to do this?

  it's actually really easy. Just specify the print () function parameter is null end it. (Default '\ n')

      Example: The following is a multiplication table, the table in the production process, want to control the change in the print line end plus (, end = "") with double and single quotes are

  for i in range(1,10):

    for j in range(1,i+1):

      print(str(i)+"*"+str(j)+"="+str(i*j)+" ",end="")
    print()

  In Python, print () function is for the default line. However, in many cases, we do not need to wrap output (such as in the algorithm contest). So, in Python how to do this?

  it's actually really easy. Just specify the print () function parameter is null end it. (Default '\ n')

      Example: The following is a multiplication table, the table in the production process, want to control the change in the print line end plus (, end = "") with double and single quotes are

  for i in range(1,10):

    for j in range(1,i+1):

      print(str(i)+"*"+str(j)+"="+str(i*j)+" ",end="")
    print()

Guess you like

Origin www.cnblogs.com/tinglele527/p/11540232.html