返回顶部
摘要: “\n” 换行符 “\t” tab缩进符 print("打印后,默认为换行,不想换行用end", end=" ") 输出内容后加个空格,不换行。 阅读全文
posted @ 2021-11-09 15:59 御用闲人 阅读(585) 评论(0) 推荐(0) 编辑
摘要: 如下所示: # 方法一:% a = "hello" b = "world!" print("你好,%s %s" % (a,b)) # 方法二:f a = "hello" b = "world!" print(f"你好,{a} {b}) 如上图,可见f方法代码量会简洁些,但它只支持python3.6及 阅读全文
posted @ 2021-11-09 15:58 御用闲人 阅读(308) 评论(0) 推荐(0) 编辑
摘要: %s 字符串 string="hello" #%s打印时结果是hello print "string=%s" % string # output: string=hello #%2s意思是字符串长度为2,当原字符串的长度超过2时,按原长度打印,所以%2s的打印结果还是hello print "str 阅读全文
posted @ 2021-11-09 15:49 御用闲人 阅读(794) 评论(0) 推荐(0) 编辑