#!/usr/bin/env python #-*-Coding:utf-8-*-system built-in functions
n =abs ( -1) #绝对值
Print (n)
#bytes () function
S= "Leave"
re= bytes (s,encoding= "utf-8") # bytes () converts a string to bytes
Print (RE)
res = str (re,encoding= "Utf-8") #转换回字符串
Print (res) re= bytes (s,encoding= "gbk") # bytes () converts a string to bytes
Print (RE)
#open函数 file Operation 3-Step open File action file Close file
#打开文件
# R-Read Only
# W Write, first empty the original file, write in
# x-only write if file exists error does not exist create and write content A-append
#以上方式 +b means reading 2 binary data directly
#r + read/write
F=open (' db ', ' W ')
F.write ("Test1,test2,test3,test4")
F.close ()
F=open (' db ', ' a ')
F.write ("/n" + "T1,T2,T3,T4")
F.close ()
F=open (' db ', ' R ')
RD = F.read ()
Rdlist = Rd.split (', ')
F.close ()
Print (rdlist)
F=open (' db ', ' r+ ', encoding= ' utf-8 ')
data = F.read ()
index= F.tell () #取得当前指针的位置 always in bytes 3 bytes of a kanji utf-8
Print (index)
F.seek (3) #把指针调整到 the first position of the parameter position
F.write ("888")
F.close ()
Python Basic Learning-built-in functions