PYTHONCHALLENGE Telegram 1607
#متن_کاوی_با_پایتون
مثال دستور find و replace

🔹 در متن جدید میخواهیم کارکتر o رو پیدا کنیم اگر از دستور find استفاده کنیم اولین کارکتر o در متن رو پیدا میکنه و اندیسش رو بعنوان خروجی برمیگردونه. (اندیس در پایتون از صفر شروع میشه)

>>> text8 = "a quick brown fox jumped over the lazy dog"
>>> text8.find('o')
10


🔹 اگر دستور rfind برای اینکار استفاده کنید آخرین کارکتر o در رشته رو پیدا میکنه، بعبارتی از آخر رشته جستجو رو انجام میده.

>>> text8.rfind('o')
40


🔹 و برای جایگزینی کارکتر o با مقدار صفر (0) میتونیم از دستور replace بصورت زیر استفاده کنیم

>>> text8.replace('o','0')
'a quick br0wn f0x jumped 0ver the lazy d0g'


🗂 مرکز آموزش پایتون

🆔 : @pythonchallenge
👍2



tgoop.com/pythonchallenge/1607
Create:
Last Update:

#متن_کاوی_با_پایتون
مثال دستور find و replace

🔹 در متن جدید میخواهیم کارکتر o رو پیدا کنیم اگر از دستور find استفاده کنیم اولین کارکتر o در متن رو پیدا میکنه و اندیسش رو بعنوان خروجی برمیگردونه. (اندیس در پایتون از صفر شروع میشه)

>>> text8 = "a quick brown fox jumped over the lazy dog"
>>> text8.find('o')
10


🔹 اگر دستور rfind برای اینکار استفاده کنید آخرین کارکتر o در رشته رو پیدا میکنه، بعبارتی از آخر رشته جستجو رو انجام میده.

>>> text8.rfind('o')
40


🔹 و برای جایگزینی کارکتر o با مقدار صفر (0) میتونیم از دستور replace بصورت زیر استفاده کنیم

>>> text8.replace('o','0')
'a quick br0wn f0x jumped 0ver the lazy d0g'


🗂 مرکز آموزش پایتون

🆔 : @pythonchallenge

BY چالش پایتون


Share with your friend now:
tgoop.com/pythonchallenge/1607

View MORE
Open in Telegram


Telegram News

Date: |

The optimal dimension of the avatar on Telegram is 512px by 512px, and it’s recommended to use PNG format to deliver an unpixelated avatar. Unlimited number of subscribers per channel The court said the defendant had also incited people to commit public nuisance, with messages calling on them to take part in rallies and demonstrations including at Hong Kong International Airport, to block roads and to paralyse the public transportation system. Various forms of protest promoted on the messaging platform included general strikes, lunchtime protests and silent sit-ins. The group also hosted discussions on committing arson, Judge Hui said, including setting roadblocks on fire, hurling petrol bombs at police stations and teaching people to make such weapons. The conversation linked to arson went on for two to three months, Hui said.
from us


Telegram چالش پایتون
FROM American