![](https://csdnimg.cn/release/download_crawler_static/86782253/bg3.jpg)
大庆油田设计院 单文冬
>>> "te" in mytext
True
>>> "tes" in mytext
False
1.5. 连接字符串
>>> mylist=["a","b","c"]
>>> stringspace="!"
>>> stringspace.join(mylist)
'a!b!c'
1.6.
分割字符串
>>> mystring="I am a student!"
>>> mylist=mystring.split(" ")
>>> print(mylist)
['I', 'am', 'a', 'student!']
>>> mytext="abcd acdb bbad"
>>> mytext.strip("bad")
'cd acdb '
lstrip()
,从左侧开始
rstrip()
,从右侧开始
replace()
,替换
1.7.
带参数输出
temp1=100
temp2=200
>>> print("The temperature1 is {0} degrees,the temperature2 is {1}".format(temp1,temp2))
The temperature1 is 100 degrees,the temperature2 is 200
>>> username = "Paul"
>>> password = "surf$&9*"
>>> print(f"{username}'s password is {password}")这个 python2.7 不行,好像 3.6 以上版本
支持。
1.8. 路径的写法
fcparcels=”c:/data/parcel.shp”
fcparcels=”c:\\data\\parcel.shp”