【python学习】字符串相关

# -*- coding: utf-8 -*-
# =============================================================================
# Ctrl + 1: 注释/反注释
# 
# Ctrl + 4/5: 块注释/块反注释
# 
# Ctrl + L: 跳转到行号
# 
# Tab/Shift + Tab: 代码缩进/反缩进
# =============================================================================

for i in range(128):
    print(chr(i).__repr__(),end=" ")

print(type('a'))

print("I'm the bone of my sword.\nSteel is my body and ...")

print("chrom\tstart\tend\tstrand\tname\tscore")
print("chr1\t520000\t530000\t+\tgene1\t0")
print("\\")

chr_, start, end = "chr1", 1000, 2000
tmpl = "gene1\nchromosome\t{}\nstart\t{}\nend\t{}"
# 这里定义了一个 模板,{} 占位处在 format 时会被替换
print(tmpl.format(chr_, start, end))

bs = b"this is a bytes"
print(type(bs))
print(bs)

#s = "hello world"
#print(s)
#s.encode('utf-8').decode('utf-16')
#print(s)

l1 = [1, "this is a str", 1.114, True]
print(l1[1:3])

 

result:

posted on 2019-07-30 20:27  tuzhuo  阅读(145)  评论(0编辑  收藏  举报