楼主: Enthuse
557 0

Python Strings [推广有奖]

  • 4关注
  • 39粉丝

已卖:995份资源

大师

8%

还不是VIP/贵宾

-

威望
0
论坛币
75391 个
通用积分
825.9999
学术水平
103 点
热心指数
114 点
信用等级
86 点
经验
299244 点
帖子
12952
精华
0
在线时间
5848 小时
注册时间
2007-4-7
最后登录
2024-1-22

楼主
Enthuse 发表于 2015-5-4 22:56:19 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
Python strings come with a powerful set of processing tools. Python has no distinct type for individual characters; instead you just
use one-character strings.

Strings are derived from sequences, and are immutable. It is easy enough to digest with examples:

S = ''   # empty string with single quotes
S ="spam's"  # double quotes
S ='s\n\p\ta\x00m'  # escape
S=""" ...multipline .."""  # triple-quoted block strings
S=r'\tmp\spam' # Raw strings (no escapes"
S=b'sp\xc4m'  # byte strings
S=u'sp\u00c5m'  # Unicode
S1+S2 # concatenation
S*3  
S[i]
S[i:j]
len(S)
"a %s parrot" % kind   # string formatting expression
S.find('pa')
S.rstrip()  # remove whitespace
S.replace('pa','xx')
S.split(',')
S.isdigit()
S.lower()
S.endswith('spam')
'spam'.jjoin(strlist)  # delimiter join
for x in S: print(x)  # iteration
'spam' in S
[c*2 for c in S]
map(ord, S)
re.match('sp(.*)am', line)  # pattern matching: library module


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:strings python string rings tring individual examples derived instead double

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
扫码
拉您进交流群
GMT+8, 2026-1-18 12:56