مانند بسیاری از زبانهای برنامه نویسی محبوب دیگر، رشتهها در پایتون آرایههایی از بایتها هستند که کاراکترهای یونیکد را نشان میدهند. با این حال، پایتون نوع داده کاراکتری ندارد، یک کاراکتر به سادگی یک رشته با طول 1 است. از براکتهای مربع میتوان برای دسترسی به عناصر رشته استفاده کرد.
🟢 مثال کاراکتر را در موقعیت 1 بدست آورید (به یاد داشته باشید که کاراکتر اول موقعیت 0 را دارد): a = "Hello, World!" print(a[1]) خروجی: e ⬅️ حلقه زدن از طریق یک رشته
از آنجایی که رشتهها آرایه هستند، میتوانیم از طریق کاراکترهای یک رشته، با یک حلقه for، حلقه بزنیم.
🟢 مثال حروف کلمه "موز" را حلقه بزنید:
for x in "banana": print(x) خروجی: b a n a n a
⬅️ طول رشته برای بدست آوردن طول یک رشته، از تابع ()len استفاده کنید.
🟢 مثال تابع len() طول یک رشته را برمی گرداند: a = "Hello, World!" print(len(a)) خروجی: 13
مانند بسیاری از زبانهای برنامه نویسی محبوب دیگر، رشتهها در پایتون آرایههایی از بایتها هستند که کاراکترهای یونیکد را نشان میدهند. با این حال، پایتون نوع داده کاراکتری ندارد، یک کاراکتر به سادگی یک رشته با طول 1 است. از براکتهای مربع میتوان برای دسترسی به عناصر رشته استفاده کرد.
🟢 مثال کاراکتر را در موقعیت 1 بدست آورید (به یاد داشته باشید که کاراکتر اول موقعیت 0 را دارد): a = "Hello, World!" print(a[1]) خروجی: e ⬅️ حلقه زدن از طریق یک رشته
از آنجایی که رشتهها آرایه هستند، میتوانیم از طریق کاراکترهای یک رشته، با یک حلقه for، حلقه بزنیم.
🟢 مثال حروف کلمه "موز" را حلقه بزنید:
for x in "banana": print(x) خروجی: b a n a n a
⬅️ طول رشته برای بدست آوردن طول یک رشته، از تابع ()len استفاده کنید.
🟢 مثال تابع len() طول یک رشته را برمی گرداند: a = "Hello, World!" print(len(a)) خروجی: 13
He said that since his platform does not have the capacity to check all channels, it may restrict some in Russia and Ukraine "for the duration of the conflict," but then reversed course hours later after many users complained that Telegram was an important source of information. On February 27th, Durov posted that Channels were becoming a source of unverified information and that the company lacks the ability to check on their veracity. He urged users to be mistrustful of the things shared on Channels, and initially threatened to block the feature in the countries involved for the length of the war, saying that he didn’t want Telegram to be used to aggravate conflict or incite ethnic hatred. He did, however, walk back this plan when it became clear that they had also become a vital communications tool for Ukrainian officials and citizens to help coordinate their resistance and evacuations. "This time we received the coordinates of enemy vehicles marked 'V' in Kyiv region," it added. Apparently upbeat developments in Russia's discussions with Ukraine helped at least temporarily send investors back into risk assets. Russian President Vladimir Putin said during a meeting with his Belarusian counterpart Alexander Lukashenko that there were "certain positive developments" occurring in the talks with Ukraine, according to a transcript of their meeting. Putin added that discussions were happening "almost on a daily basis." Telegram boasts 500 million users, who share information individually and in groups in relative security. But Telegram's use as a one-way broadcast channel — which followers can join but not reply to — means content from inauthentic accounts can easily reach large, captive and eager audiences.
from ca