name = input( 'please enter your name:' )print (name)
value1 = 1024 * 512value2 = input('num1:')value3 = input('num2:')print (value1)print (value2)print (value3)print (value1 * value2)print (value1 * value3)#当value2 * value3的时候不能如上表示
s = "Wind and cloud"weather1 = "Wind" in sweather2 = "SB" in sprint (weather1)print (weather2)
Wind = "weather1"Paul = "name"Rain = "weather2"_Coll_1 = ['Wind','Paul','Rain']print(_Coll_1)_Cont_1 = "Wind" in _Coll_1print (_Cont_1)
temp1 = "123"_123_io = type(temp1)print(_123_io)temp2 = "hey"_hey_io = type(temp2)print(_hey_io)
temp = "wind"print(dir(temp))
temp = "wind"print(temp.upper())
_name_coll = ("paul,vencent,sunny,anny,should,bilibili,david,paul")_coll = _name_coll.count("nn")print(_coll)
temp = "hello"print(temp.endswith('e',0,2)) #字符串的0-2的字符he,是以e结尾,python中如果从字符串开头查找字符,必须从0位开始
a1 = "alex"a2 = a1.center(20,'*')print(a2)#字符总数20个,以alex为中心,两边以*号填充
a1 = "alex is alpa"a2 = a1.count('al',5,12)print(a2)
content = "hellot123"print(content)print(content.expandtabs())print(content.expandtabs(20))
s = "alex hello"print(s.find("h"))print(s.find("p"))#找不到的字符,会显示负数
str = 'Runoob'print (str[0:3])print (str[0])print (str[2:5])print (str[2:])print (str * 2)print (str + "TEST")
print('Runnoob')print(r'Runnoob')
x = "hello {0}, age {1}"print(x)y = x.format("paul","27")print(y)
alex = "name1"should = "name2"paul = "name3"dio = "name5"name = [alex ,should ,paul ,dio]_name_join = "".join(name)print(_name_join)#将值变成一个整体字符串输出,如果不用元组,只是字符串,可以使用双引号把字符串引起来,加入空格,是字符串相互隔开。name = "alex ","should ","paul ","dio "print (name)_name_join = "".join(name)print(_name_join)
x = "alex is alex"y = x.replace("al","AA")print(y)
x = "alexnalex"y = x.split()print(y)
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2530/viewspace-2809683/ ,如需转载,请注明出处,否则将追究法律责任。