方法集锦3_字符串_python

qinyuehong 2020-05-06

1.字符串拼接,join和列表的配合使用

a = ‘‘
d = [‘d‘,‘h‘,‘t‘,‘dg‘,‘gh‘]
a = a.join(i for i in d)
print(a)

运行结果:

PS D:\Python\Code_Python\lintcode> & D:/python_install/python.exe d:/Python/Code_Python/lintcode/lintcode_test12.py
dhtdggh

相关推荐