r*******n 发帖数: 3020 | 1 how to reverse a string.
For example:
string = 'I am a Chinese'
reverse_string = string[::-1]
To make this club active, anybody? | i*****f 发帖数: 578 | 2 Thanks for sharing, runPy! Great example! Slicing is **REALLY** amazing and
convenience in Python (Also seen it in Matlab, sort of)
OK, I'll give another example, the list comprehension
a = [1,2,3,4]
# now I want [2,4,6,8]
b = [ 2*x for x in a ] # haha! | a**a 发帖数: 416 | 3 recommand http://www.dabeaz.com/generators/Generators.pdf
and
【在 i*****f 的大作中提到】 : Thanks for sharing, runPy! Great example! Slicing is **REALLY** amazing and : convenience in Python (Also seen it in Matlab, sort of) : OK, I'll give another example, the list comprehension : a = [1,2,3,4] : # now I want [2,4,6,8] : b = [ 2*x for x in a ] # haha!
| i*****f 发帖数: 578 | 4 thanks for sharing generators slides!
【在 a**a 的大作中提到】 : recommand http://www.dabeaz.com/generators/Generators.pdf : : and
|
|