python - 在 Python 中连接压缩值

标签 python

我刚刚开始学习Python。 请告诉我如何连接它。

a='abc'
b='123'

作为我想要的输出:

[(a1, b2, c3)]

我尝试使用内置的 zip() 函数,但结果是 (a, 1), (a, 2), (a, 3)

最佳答案

因为你可以直接将两个字符串相加,所以你可以尝试:

[x+y for x,y in zip(a,b)]

关于python - 在 Python 中连接压缩值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51482134/

相关文章:

python - 导入错误 : No module named 'wordcloud'

python - 如何使用 python 中的 Github api 从字符串计算 SHA?

python - pycrypto 需要 Visual Studio 吗?

python - python中的缓冲区是什么意思

python - 使用 nopython 模式在 numba 装饰器@njit 中为字符串的 ndarray 签名

python - 使用 Perl 的 B::Concise 之类的东西转储 Python opttree?

python - 如何使用python将itk图像文件转换为vtk?

python - 对于大文件,Python 中的整数数据输入 -> 平均 -> float 据输出

python - Django 中将foreignkey 放在哪里?

python - 如何使用 scikit 学习具有新值的 inverse_transform