输出不换行: 在python 2.x版本中,使用“,”,不含双引号
print '*',
还有一种方法:在上一行输入sys.stdout.write,下一行输出才没有换行,如下代码:
# vi iptest.py
#! /bin/bash
# -*- coding: utf-8 -*-
import time,shutil,os,sys
print ("11"),
print ("12")
sys.stdout.write('11')
print ("12")
输出如下代码
11 12
1112
print '',和sys.stdout.write区别输出是否有空格,使用“,”是有空格。
在python 3.x版本中
print(x, end="")
输出换行分隔符
中间添加 print('')即可
参考: